Commit 6caf4810 authored by nanahira's avatar nanahira

remove match tree

parent 345755c3
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nesties": "^1.1.1", "nesties": "^1.1.1",
"nestjs-mycard": "^4.0.2", "nestjs-mycard": "^4.0.2",
"nicot": "^1.1.13", "nicot": "^1.1.17",
"pg": "^8.14.1", "pg": "^8.14.1",
"pg-native": "^3.3.0", "pg-native": "^3.3.0",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",
...@@ -6352,6 +6352,12 @@ ...@@ -6352,6 +6352,12 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
"license": "MIT"
},
"node_modules/events": { "node_modules/events": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
...@@ -9061,13 +9067,14 @@ ...@@ -9061,13 +9067,14 @@
} }
}, },
"node_modules/nicot": { "node_modules/nicot": {
"version": "1.1.13", "version": "1.1.17",
"resolved": "https://registry.npmjs.org/nicot/-/nicot-1.1.13.tgz", "resolved": "https://registry.npmjs.org/nicot/-/nicot-1.1.17.tgz",
"integrity": "sha512-uBDjRUx/jmuUGxQeC/KtmkP8C/QIZYRYJMYJuszAV7M1Na+Um9hnHTcTWeSK+whrXoIEt8bJlERFn/CnRTi06A==", "integrity": "sha512-80Bj537a/KJZNbK5RyAf0NNzrmtygQuX0OOAkLGlmYwaTxmSqNTJ/NyWiao+ObUIu6GG3HM68erhcxSgK6ihhA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nesties": "^1.1.2", "nesties": "^1.1.2",
"p-queue": "6.6.2",
"superjson": "1.13.3", "superjson": "1.13.3",
"typed-reflector": "^1.0.11" "typed-reflector": "^1.0.11"
}, },
...@@ -9290,6 +9297,15 @@ ...@@ -9290,6 +9297,15 @@
"node": ">=12.20" "node": ">=12.20"
} }
}, },
"node_modules/p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/p-limit": { "node_modules/p-limit": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
...@@ -9322,6 +9338,34 @@ ...@@ -9322,6 +9338,34 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/p-queue": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.6.2.tgz",
"integrity": "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==",
"license": "MIT",
"dependencies": {
"eventemitter3": "^4.0.4",
"p-timeout": "^3.2.0"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-timeout": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz",
"integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==",
"license": "MIT",
"dependencies": {
"p-finally": "^1.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": { "node_modules/p-try": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
......
...@@ -134,6 +134,7 @@ export class Match extends IdBase() { ...@@ -134,6 +134,7 @@ export class Match extends IdBase() {
return this.player1Id === id ? this.player2Id : this.player1Id; return this.player1Id === id ? this.player2Id : this.player1Id;
} }
/*
clone() { clone() {
const match = new Match(); const match = new Match();
Object.assign(match, this); Object.assign(match, this);
...@@ -146,4 +147,5 @@ export class Match extends IdBase() { ...@@ -146,4 +147,5 @@ export class Match extends IdBase() {
.map((match) => match.clone().buildTree(matches)); .map((match) => match.clone().buildTree(matches));
return this; return this;
} }
*/
} }
...@@ -158,12 +158,14 @@ export class Tournament extends DescBase { ...@@ -158,12 +158,14 @@ export class Tournament extends DescBase {
@OneToMany(() => Match, (match) => match.tournament) @OneToMany(() => Match, (match) => match.tournament)
matches: Match[]; matches: Match[];
/*
@NotColumn() @NotColumn()
@ApiProperty({ @ApiProperty({
description: '对阵图树', description: '对阵图树',
}) })
@RelationComputed() @RelationComputed()
matchTree: Match; matchTree: Match;
*/
async beforeCreate() { async beforeCreate() {
this.createdAt = new Date(); this.createdAt = new Date();
...@@ -234,6 +236,7 @@ export class Tournament extends DescBase { ...@@ -234,6 +236,7 @@ export class Tournament extends DescBase {
}); });
} }
/*
calculateTree() { calculateTree() {
const finalMatch = _.maxBy( const finalMatch = _.maxBy(
this.matches.filter((m) => !m.isThirdPlaceMatch), this.matches.filter((m) => !m.isThirdPlaceMatch),
...@@ -241,6 +244,7 @@ export class Tournament extends DescBase { ...@@ -241,6 +244,7 @@ export class Tournament extends DescBase {
); );
this.matchTree = finalMatch.clone().buildTree(this.matches); this.matchTree = finalMatch.clone().buildTree(this.matches);
} }
*/
analytics() { analytics() {
if (!this.participants || this.status === TournamentStatus.Ready) { if (!this.participants || this.status === TournamentStatus.Ready) {
...@@ -248,7 +252,7 @@ export class Tournament extends DescBase { ...@@ -248,7 +252,7 @@ export class Tournament extends DescBase {
} }
this.calculateScore(); this.calculateScore();
if (this.rule === TournamentRule.SingleElimination) { if (this.rule === TournamentRule.SingleElimination) {
this.calculateTree(); // this.calculateTree();
} }
} }
} }
...@@ -17,6 +17,7 @@ const factory = new RestfulFactory(Tournament, { ...@@ -17,6 +17,7 @@ const factory = new RestfulFactory(Tournament, {
'matches.player1', 'matches.player1',
'matches.player2', 'matches.player2',
'matches.winner', 'matches.winner',
/*
'matchTree', 'matchTree',
'matchTree.player1', 'matchTree.player1',
'matchTree.player2', 'matchTree.player2',
...@@ -29,6 +30,7 @@ const factory = new RestfulFactory(Tournament, { ...@@ -29,6 +30,7 @@ const factory = new RestfulFactory(Tournament, {
'matchTree.parentMatches.parentMatches.player1', 'matchTree.parentMatches.parentMatches.player1',
'matchTree.parentMatches.parentMatches.player2', 'matchTree.parentMatches.parentMatches.player2',
'matchTree.parentMatches.parentMatches.winner', 'matchTree.parentMatches.parentMatches.winner',
*/
], ],
}); });
class CreateTournamentDto extends factory.createDto {} class CreateTournamentDto extends factory.createDto {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment