Merged
Conversation
Comment on lines
+42
to
+52
| var end_datetime = end_date.ToDateTime(TimeOnly.MaxValue); | ||
| var feedbacks = (from feedback in _context.Feedbacks | ||
| join round in _context.Rounds on feedback.RoundId equals round.Id | ||
| orderby round.Id | ||
| where feedback.KeyName == key_name | ||
| && round.ShutdownDatetime != null | ||
| && round.InitializeDatetime >= start_datetime | ||
| && round.InitializeDatetime <= end_datetime | ||
| // feedback.JSON begins with `{"data": ...` so we strip the first curly brace | ||
| // in order to interpolate the rest of the JSON data into the resultant string | ||
| select $"{{\"round_id\": {round.Id}, {feedback.Json.Substring(1)}"); |
Contributor
Author
There was a problem hiding this comment.
this manages to resolve to a single query, including the substring manip, which is pretty cool:
SELECT `r`.`id`,
SUBSTRING(`f`.`json`, 1 + 1, CHAR_LENGTH(`f`.`json`))
FROM `feedback` AS `f`
INNER JOIN `round` AS `r`
ON `f`.`round_id` = `r`.`id`
WHERE (((`f`.`key_name` = @__key_name_0)
AND `r`.`shutdown_datetime` IS NOT NULL)
AND (`r`.`initialize_datetime` >= @__start_datetime_1))
AND (`r`.`initialize_datetime` <= @__end_datetime_2)
ORDER BY `r`.`id`
Contrabang
reviewed
Aug 21, 2025
Comment on lines
+55
to
+59
| { | ||
| Content = "[" + string.Join(", ", feedbacks) + "]", | ||
| ContentType = "application/json", | ||
| StatusCode = 200 | ||
| }; |
Member
There was a problem hiding this comment.
I hate that we are manually constructing JSON but this PR has been up long enough.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR creates a v2 API namespace for Parastats, and adds its first method.
Besides any new API endpoints not present on v1, the v2 namespace is differentiated because it returns JSON-formatted results of feedback data, rather than a stringified JSON value.
/v2/stats/feedback:key_name, and two dates,start_dateandend_date, which must consist of a span of two months max.key_name.This makes it painless to quickly perform queries on individual feedback keys and helps to lessen the need for mirroring feedback data locally:
The LINQ query resolves nicely into a single SQL query which runs quickly. Concatenating the strings together the way we're doing here is a tiny bit slower, but not egregiously so for queries limited to two months max.