Skip to content

Commit

Permalink
Fully implemented rankings update.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-flynn committed Aug 15, 2019
1 parent e814720 commit 327a198
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion ems-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"typescript": "^3.4.5"
},
"dependencies": {
"@the-orange-alliance/lib-ems": "^0.4.8",
"@the-orange-alliance/lib-ems": "^0.5.18",
"appdata-path": "^1.0.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
Expand Down
2 changes: 1 addition & 1 deletion ems-api/src/controllers/Ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ router.get("/calculate/:tournament_level", (req: Request, res: Response, next: N
if (rankJSON.length > 0) {
const promises: Array<Promise<any>> = [];
for (const ranking of rankJSON) {
if (typeof ranking.team !== "undefined") delete ranking.team;
delete ranking.team;
promises.push(DatabaseManager.updateWhere("ranking", ranking, "rank_key=\"" + ranking.rank_key + "\""));
}
Promise.all(promises).then((values: any[]) => {
Expand Down
2 changes: 1 addition & 1 deletion ems-core/package.electron.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ems-core",
"author": "The Orange Alliance",
"description": "An improved event experience.",
"version": "2.12.2",
"version": "2.13.0",
"private": true,
"main": "public/desktop/electron.js",
"homepage": "./public/desktop/",
Expand Down
4 changes: 2 additions & 2 deletions ems-core/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ems-core",
"version": "2.12.2",
"version": "2.13.0",
"private": true,
"main": "build/electron.js",
"dependencies": {
"@the-orange-alliance/lib-ems": "^0.5.12",
"@the-orange-alliance/lib-ems": "^0.5.18",
"axios": "^0.19.0",
"dotenv": "^8.0.0",
"local-ipv4-address": "0.0.2",
Expand Down
33 changes: 17 additions & 16 deletions ems-core/src/managers/FGCUploadManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
EMSProvider, Event, FGCProvider, HttpError, Match, MatchDetails, MatchParticipant, Ranking, Team
EMSProvider, Event, EventType, FGCProvider, HttpError, Match, MatchDetails, MatchParticipant, Ranking,
Team
} from "@the-orange-alliance/lib-ems";
import TeamValidator from "../validators/TeamValidator";

Expand Down Expand Up @@ -98,13 +99,14 @@ class FGCUploadedManager {
promises.push(FGCProvider.putMatchResults(eventKey, match));
promises.push(FGCProvider.putMatchDetails(eventKey, match.matchDetails));
promises.push(FGCProvider.putMatchParticipants(eventKey, match.participants));
const seasonKey: string = match.matchKey.split("-")[0];
Promise.all(promises).then(() => {
if (match.tournamentLevel > 0 && match.tournamentLevel < 10) {
FGCProvider.deleteRankings(eventKey).then(() => {
FGCProvider.deleteRankingsByLevel(eventKey, match.tournamentLevel).then(() => {
setTimeout(() => {
EMSProvider.getRankings().then((rankings: Ranking[]) => {
EMSProvider.getRankings(getEventTypeFromKey(seasonKey)).then((rankings: Ranking[]) => {
if (rankings.length > 0) {
FGCProvider.postRankings(eventKey, rankings).then(() => {
FGCProvider.postRankingsByLevel(eventKey, rankings, match.tournamentLevel).then(() => {
resolve();
}).catch((postError: HttpError) => {
reject(postError);
Expand All @@ -129,17 +131,16 @@ class FGCUploadedManager {
}

}
//
// function getPartialFromLevel(tournamentLevel: number): string {
// if (tournamentLevel === 0) {
// return "P";
// } else if (tournamentLevel === 1) {
// return "Q";
// } else if (tournamentLevel >= 10) {
// return "E";
// } else {
// return "";
// }
// }

function getEventTypeFromKey(seasonKey: string): EventType | undefined {
switch (seasonKey) {
case "2018":
return "fgc_2018";
case "2019":
return "fgc_2019";
default:
return undefined;
}
}

export default FGCUploadedManager.getInstance();
2 changes: 1 addition & 1 deletion ems-core/src/managers/MatchManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class MatchManager {
match.matchDetails.matchKey = match.matchKey;
match.matchDetails.matchDetailKey = match.matchDetailKey;
for (const participant of match.participants) {
if (typeof participant.cardStatus === "undefined") {
if (typeof participant.cardStatus === "undefined" || (participant.cardStatus as any) === "null") {
participant.cardStatus = 0;
}
}
Expand Down
17 changes: 9 additions & 8 deletions ems-core/src/views/match-review/MatchReviewView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import DialogManager from "../../managers/DialogManager";
import {IDisableNavigation} from "../../stores/internal/types";
import {disableNavigation} from "../../stores/internal/actions";
import ConfirmActionModal from "../../components/ConfirmActionModal";
import TOAUploadManager from "../../managers/TOAUploadManager";
import {
Event, EventConfiguration, HttpError, Match, MatchDetails, MatchParticipant,
TournamentType, TOAConfig, EliminationMatchesFormat
} from "@the-orange-alliance/lib-ems";
import UploadManager from "../../managers/UploadManager";

interface IProps {
event?: Event,
Expand Down Expand Up @@ -207,15 +207,16 @@ class MatchReviewView extends React.Component<IProps, IState> {
this.setState({updatingScores: true, confirmModalOpen: false});
this.props.activeMatch.matchDetails = this.props.activeDetails;
this.props.activeMatch.participants = this.props.activeParticipants;
if (this.props.toaConfig.enabled) {
TOAUploadManager.postMatchResults(this.props.event.eventKey, this.props.activeMatch).then(() => {
console.log(`Uploaded match results for ${this.props.activeMatch.matchKey}`);
}).catch((error: HttpError) => {
DialogManager.showErrorBox(error);
});
}
const tournamentRound = Array.isArray(this.props.eventConfig.tournament) ? this.props.eventConfig.tournament[0] : this.props.eventConfig.tournament; // TODO - CHANGE
MatchManager.commitScores(this.props.activeMatch, this.props.eventConfig).then(() => {
if (this.props.toaConfig.enabled) {
UploadManager.postMatchResults(this.props.event.eventKey, this.props.activeMatch).then(() => {
console.log(`Uploaded match results for ${this.props.activeMatch.matchKey}`);
}).catch((error: HttpError) => {
DialogManager.showErrorBox(error);
});
}

this.props.setNavigationDisabled(false);
this.setState({updatingScores: false});
if (this.props.activeMatch.tournamentLevel >= 10) {
Expand Down

0 comments on commit 327a198

Please sign in to comment.