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

🎨 Refactor: move route func's to separate handlers #2670

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a2bac9d
:art: refactor: move matches route handler to separate module
ff137 Sep 15, 2023
3fb904f
:art: refactor: move playersByRank route handler to separate module
ff137 Sep 15, 2023
83c56b9
:art: refactor: move getPlayersByAccountId route handler to players m…
ff137 Sep 15, 2023
da1ede6
:art: refactor: move getPlayersByAccountIdWl route handler to players…
ff137 Sep 15, 2023
e5bda04
:art: refactor: move getPlayersByAccountIdRecentMatches route handler…
ff137 Sep 15, 2023
427f04e
:art: refactor: move getPlayersByAccountIdMatches route handler to pl…
ff137 Sep 15, 2023
a7064d0
:art: refactor: move getPlayersByAccountIdHeroes route handler to pla…
ff137 Sep 15, 2023
7334731
:art: refactor: move getPlayersByAccountIdPeers route handler to play…
ff137 Sep 15, 2023
2632f2d
:art: refactor: move getPlayersByAccountIdPros route handler to playe…
ff137 Sep 15, 2023
31bc13b
:art: refactor: move getPlayersByAccountIdTotals route handler to pla…
ff137 Sep 15, 2023
f1d7274
:art: refactor: move getPlayersByAccountIdCounts route handler to pla…
ff137 Sep 15, 2023
df7f01d
:art: refactor: move getPlayersByAccountIdHistogramsByField route han…
ff137 Sep 15, 2023
0ddf937
:art: refactor: move getPlayersByAccountIdWardMap route handler to pl…
ff137 Sep 15, 2023
bcb3cd0
:art: refactor: move getPlayersByAccountIdWordCloud route handler to …
ff137 Sep 15, 2023
32b9c89
:art: refactor: move getPlayersByAccountIdRatings route handler to pl…
ff137 Sep 15, 2023
4dfd502
:art: refactor: move getPlayersByAccountIdRankings route handler to p…
ff137 Sep 15, 2023
26774c7
:art: refactor: move getPlayersByAccountIdRefresh route handler to pl…
ff137 Sep 15, 2023
97fbef6
:art: refactor: move getProPlayers route handler to players module
ff137 Sep 15, 2023
39d8050
exports
ff137 Sep 15, 2023
cd75ab9
:art: imports
ff137 Sep 15, 2023
5813fc0
:art: drop `async` from method definition, as await is not used
ff137 Sep 15, 2023
41b130a
:art: refactor: move getProMatches route handler to matches module
ff137 Sep 15, 2023
f8b22e6
:art: refactor: move getPublicMatches route handler to matches module
ff137 Sep 15, 2023
0614143
:art: refactor: move getParsedMatches route handler to matches module
ff137 Sep 15, 2023
f549ee7
:art: refactor: move getHeroRankings route handler to heroes module
ff137 Sep 15, 2023
ba82edf
:art: refactor: move searchPlayers route handler to players module
ff137 Sep 15, 2023
a7a1523
:art: refactor: move findMatches route handler to matches module
ff137 Sep 15, 2023
b59f730
:art: refactor: move getHeroBenchmarks route handler to heroes module
ff137 Sep 15, 2023
5b03eb4
:art: refactor: move getHeroData route handler to heroes module
ff137 Sep 15, 2023
a2e3da3
:art: refactor: move getHeroStats route handler to heroes module
ff137 Sep 15, 2023
488348e
:art: refactor: move getRecentMatchesByHeroId route handler to heroes…
ff137 Sep 15, 2023
6284575
:art: refactor: move getMatchupsByHeroId route handler to heroes module
ff137 Sep 15, 2023
910c3d4
:art: refactor: move getMatchDurationsByHeroId route handler to heroe…
ff137 Sep 15, 2023
24ecf8b
:art: refactor: move getPlayersByHeroId route handler to heroes module
ff137 Sep 15, 2023
0154323
:art: refactor: move getItemPopularityByHeroId route handler to heroe…
ff137 Sep 15, 2023
0de8e7e
:art:
ff137 Sep 15, 2023
2b1ea95
:art: refactor: move getTeamsData route handler to teams module
ff137 Sep 15, 2023
49a971a
:art: refactor: move getTeamById route handler to teams module
ff137 Sep 15, 2023
746d9a9
:art: refactor: move getMatchesByTeamId route handler to teams module
ff137 Sep 15, 2023
2f2a621
:art: refactor: move getPlayersByTeamId route handler to teams module
ff137 Sep 15, 2023
e557db7
:art: refactor: move getHeroesByTeamId route handler to teams module
ff137 Sep 15, 2023
2aa319c
:art: refactor: move explorer route handler to database module
ff137 Sep 15, 2023
d93be57
:art: refactor: move getLeagues route handler to leagues module
ff137 Sep 15, 2023
75b3386
:art: refactor: move getLeaguesById route handler to leagues module
ff137 Sep 15, 2023
c592f82
:art: refactor: move getMatchesByLeagueId route handler to leagues mo…
ff137 Sep 15, 2023
b805713
:art: refactor: move getTeamsByLeagueId route handler to leagues module
ff137 Sep 15, 2023
dc34b17
:art: refactor: move getSchema route handler to database module
ff137 Sep 15, 2023
a9a6e6a
:art: refactor: move getMmrDistributions route handler to database mo…
ff137 Sep 15, 2023
2f0ea1a
:art: refactor: move getBuildStatus route handler to database module
ff137 Sep 15, 2023
9b4e382
:art: refactor: move getLiveMatches route handler to matches module
ff137 Sep 15, 2023
9e2f09e
:art: refactor: move getRecordsByField route handler to database module
ff137 Sep 15, 2023
3446c39
:art: refactor: move getReplayData route handler to database module
ff137 Sep 15, 2023
29ad7e0
:art: refactor: move requestParse and getRequestState route handler t…
ff137 Sep 15, 2023
ab2fee5
:art: refactor: move getMetadata route handler to database module
ff137 Sep 15, 2023
9db9772
:art: refactor: move getHealth route handler to database module
ff137 Sep 15, 2023
463a87a
:art: refactor: move getConstants and getConstantsByResource route ha…
ff137 Sep 15, 2023
6c709db
:art: refactor: move scenario route handlers to database module
ff137 Sep 15, 2023
8f16935
:art:
ff137 Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🎨 refactor: move getMatchesByTeamId route handler to teams module
  • Loading branch information
ff137 committed Sep 15, 2023
commit 746d9a99a910c165febde5d89a14d31064240a13
22 changes: 22 additions & 0 deletions routes/handlers/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,29 @@ function getTeamById(req, res, cb) {
});
}

function getMatchesByTeamId(req, res, cb) {
db.raw(
`
SELECT team_match.match_id, radiant_win, radiant_score, dire_score, team_match.radiant, duration, start_time, leagueid, leagues.name as league_name, cluster, tm2.team_id opposing_team_id, teams2.name opposing_team_name, teams2.logo_url opposing_team_logo
FROM team_match
JOIN matches USING(match_id)
JOIN leagues USING(leagueid)
JOIN team_match tm2 on team_match.match_id = tm2.match_id and team_match.team_id != tm2.team_id
JOIN teams teams2 on tm2.team_id = teams2.team_id
WHERE team_match.team_id = ?
ORDER BY match_id DESC
`,
[req.params.team_id]
).asCallback((err, result) => {
if (err) {
return cb(err);
}
return res.json(result.rows);
});
}

module.exports = {
getTeamsData,
getTeamById,
getMatchesByTeamId,
};
21 changes: 1 addition & 20 deletions routes/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,26 +1519,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque
},
},
route: () => "/teams/:team_id/matches",
func: (req, res, cb) => {
db.raw(
`
SELECT team_match.match_id, radiant_win, radiant_score, dire_score, team_match.radiant, duration, start_time, leagueid, leagues.name as league_name, cluster, tm2.team_id opposing_team_id, teams2.name opposing_team_name, teams2.logo_url opposing_team_logo
FROM team_match
JOIN matches USING(match_id)
JOIN leagues USING(leagueid)
JOIN team_match tm2 on team_match.match_id = tm2.match_id and team_match.team_id != tm2.team_id
JOIN teams teams2 on tm2.team_id = teams2.team_id
WHERE team_match.team_id = ?
ORDER BY match_id DESC
`,
[req.params.team_id]
).asCallback((err, result) => {
if (err) {
return cb(err);
}
return res.json(result.rows);
});
},
func: teamsHandler.getMatchesByTeamId,
},
},
"/teams/{team_id}/players": {
Expand Down