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

Add minRank and maxRank query parameters to /publicMatches #2662

Merged
merged 15 commits into from
Jun 25, 2023

Conversation

ff137
Copy link
Contributor

@ff137 ff137 commented Jun 21, 2023

Adds minRank and maxRank query parameters and uses avg_rank_tier field in public_matches to filter results.

    "/publicMatches": {
      get: {
...
        parameters: [
          { $ref: "#/components/parameters/lessThanMatchIdParam" },
          { $ref: "#/components/parameters/minRankParam" },
          { $ref: "#/components/parameters/maxRankParam" },
          { $ref: "#/components/parameters/mmrAscendingParam" },
          { $ref: "#/components/parameters/mmrDescendingParam" },
        ],
...
        route: () => "/publicMatches",
        func: async (req, res, cb) => {
...
          if (req.query.mmr_ascending) {
            order = "ORDER BY avg_rank_tier ASC NULLS LAST";
          } else if (req.query.mmr_descending) {
            order = "ORDER BY avg_rank_tier DESC NULLS LAST";
          } else {
            order = "ORDER BY match_id DESC";
            moreThan = 0;
          }
          let minRank= req.query.min_rank
            ? `AND avg_rank_tier >= ${req.query.min_rank}`
            : "";
          let maxRank= req.query.max_rank
            ? `AND avg_rank_tier <= ${req.query.max_rank}`
            : "";

          db.raw(
            `
          WITH match_ids AS (SELECT match_id FROM public_matches
          WHERE TRUE
          AND match_id > ?
          AND match_id < ?
          ${minRank}
          ${maxRank}
          ${order}
          LIMIT 100)
          SELECT * FROM
...

@ff137 ff137 changed the title Add minMmr and maxMmr query parameters to /pubmatches Add minMmr and maxMmr query parameters to /publicMatches Jun 21, 2023
Copy link
Member

@builder-247 builder-247 left a comment

Choose a reason for hiding this comment

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

I'm pretty sure the mmr field isn't being updated anymore, average_rank should be used instead

@ff137
Copy link
Contributor Author

ff137 commented Jun 21, 2023

I'm pretty sure the mmr field isn't being updated anymore, average_rank should be used instead

Oh, ok. I was just going off the response from: https://api.opendota.com/api/publicMatches

In that case, avg_mmr should probably be removed from the response? To avoid confusion. Or, avg_mmr should be implemented again? Is there a reason it's not being updated anymore?

@ff137 ff137 changed the title Add minMmr and maxMmr query parameters to /publicMatches Add minRank and maxRank query parameters to /publicMatches Jun 21, 2023
@ff137
Copy link
Contributor Author

ff137 commented Jun 21, 2023

@howardchung I notice the indenting in the spec description causes it to render like this:
image

Included a fix for that

@howardchung howardchung merged commit 7936584 into odota:master Jun 25, 2023
1 check passed
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