Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats in JSON format #686

Merged
merged 8 commits into from
Sep 26, 2021
Merged

Stats in JSON format #686

merged 8 commits into from
Sep 26, 2021

Conversation

jenrik
Copy link
Contributor

@jenrik jenrik commented Jul 17, 2021

Add support for writing stats in JSON format.

The feature is enabled by setting the get5_stats_path_format cvar to a value ending in .json

The work is paid for in part by ehub.gg

}
}

public bool DumpToFilePath(const char[] path) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion:

  • Add a generic IsJSONPath function to util.sp
  • That implementation can be simplified doing something like: StrCompare(path[path_length - 5], ".json") == 0 (after validating path_length > 5 still)
  • Replace this with a call to that function
  • Make this function: return IsJSONPath(path) : DumpToJSONFile(path) : g_StatsKv.ExportToFile(path);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in a3e9d2b

}

char jsonBuffer[8192]; // 8 KiB
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how large the json data is in practice TBH, I'm wondering if 8KiB is enough; do you have a sense of the size for a normal 10-person 3-map match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a guess based on intuition. I tried 32 KiB but that crashed with a out of heap or stack space error (I don't recall which)

IsJSONPath checks if the path ends in ".json".
Change DumpToFilePath and LoadMatchFile to use IsJSONPath.
@jenrik jenrik requested a review from splewis July 21, 2021 14:08
@ErcouldnT
Copy link

Hi, sir

I have just started this project about JSON match stats.

If you are able to send match stats JSON body as a POST request to a server set with get5_match_stats_api_url that would be awesome!

Erkut

@splewis splewis merged commit 43b7f3d into splewis:master Sep 26, 2021
PhlexPlexico added a commit to PhlexPlexico/get5 that referenced this pull request Dec 16, 2021
Add in global forwards.

Update debug calls.

Update misused sizeof.

Include timer to make sure unpause event fires off.

Having to create new timer to keep track of unpause event.

Additional comments.

Move team for when timer is finished.

Include global handler for p;ause time.

This is needed if users !pause during the match.

Use freeze time, it works as intended.

Fixes based on comments.

Remove Handler.

Bump to 0.8.0-dev, since splewis#612 will have breaking eventlogger changes.

(Squashed): Added knife kills, utility damage and enemies/team-flash tracking (splewis#612)

Use game-provided flash-assist logic

Stats in JSON format (splewis#686)

* Dump stats in JSON format

* update sm-json

* Fix malformed JSON stats

Fixed code not entering the inital "Stats" section.
Moved the section name extraction to avoid messing with the traversal
stack.

* Reduced JSON stats buffer to avoid "out of heap" errors

* Add debug log when trying to JSON encode unsupported type

* Only dump stats in JSON format if stats file have json extension

* Util function for checking json extension

IsJSONPath checks if the path ends in ".json".
Change DumpToFilePath and LoadMatchFile to use IsJSONPath.
PhlexPlexico added a commit to PhlexPlexico/get5 that referenced this pull request Dec 16, 2021
Add in global forwards.

Update debug calls.

Update misused sizeof.

Include timer to make sure unpause event fires off.

Having to create new timer to keep track of unpause event.

Additional comments.

Move team for when timer is finished.

Include global handler for p;ause time.

This is needed if users !pause during the match.

Use freeze time, it works as intended.

Fixes based on comments.

Remove Handler.

Bump to 0.8.0-dev, since splewis#612 will have breaking eventlogger changes.

(Squashed): Added knife kills, utility damage and enemies/team-flash tracking (splewis#612)

Use game-provided flash-assist logic

Stats in JSON format (splewis#686)

* Dump stats in JSON format

* update sm-json

* Fix malformed JSON stats

Fixed code not entering the inital "Stats" section.
Moved the section name extraction to avoid messing with the traversal
stack.

* Reduced JSON stats buffer to avoid "out of heap" errors

* Add debug log when trying to JSON encode unsupported type

* Only dump stats in JSON format if stats file have json extension

* Util function for checking json extension

IsJSONPath checks if the path ends in ".json".
Change DumpToFilePath and LoadMatchFile to use IsJSONPath.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants