@opprs/db-prisma 2.6.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -18
- package/dist/index.cjs +0 -419
- package/dist/index.d.cts +3 -392
- package/dist/index.d.ts +3 -392
- package/dist/index.js +0 -379
- package/package.json +4 -3
- package/prisma/migrations/20260105020000_add_blog_post_model/migration.sql +81 -0
- package/prisma/migrations/20260109000000_remove_entry_match_round_models/migration.sql +26 -0
- package/prisma/schema.prisma +0 -71
package/LICENSE
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
OPPRS - pinball tournament software
|
|
2
|
+
Copyright (C) 2026 Mitch McAffee
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
package/dist/index.cjs
CHANGED
|
@@ -25,14 +25,11 @@ __export(index_exports, {
|
|
|
25
25
|
connect: () => connect,
|
|
26
26
|
countBlogPosts: () => countBlogPosts,
|
|
27
27
|
countBlogTags: () => countBlogTags,
|
|
28
|
-
countEntries: () => countEntries,
|
|
29
28
|
countLocations: () => countLocations,
|
|
30
|
-
countMatches: () => countMatches,
|
|
31
29
|
countOpprPlayerRankings: () => countOpprPlayerRankings,
|
|
32
30
|
countOpprRankingHistory: () => countOpprRankingHistory,
|
|
33
31
|
countPlayers: () => countPlayers,
|
|
34
32
|
countPublishedBlogPosts: () => countPublishedBlogPosts,
|
|
35
|
-
countRounds: () => countRounds,
|
|
36
33
|
countStandings: () => countStandings,
|
|
37
34
|
countTournaments: () => countTournaments,
|
|
38
35
|
countUserApiKeys: () => countUserApiKeys,
|
|
@@ -40,17 +37,11 @@ __export(index_exports, {
|
|
|
40
37
|
createApiKey: () => createApiKey,
|
|
41
38
|
createBlogPost: () => createBlogPost,
|
|
42
39
|
createBlogTag: () => createBlogTag,
|
|
43
|
-
createEntry: () => createEntry,
|
|
44
40
|
createLocation: () => createLocation,
|
|
45
|
-
createManyEntries: () => createManyEntries,
|
|
46
|
-
createManyMatches: () => createManyMatches,
|
|
47
|
-
createManyRounds: () => createManyRounds,
|
|
48
41
|
createManyStandings: () => createManyStandings,
|
|
49
|
-
createMatch: () => createMatch,
|
|
50
42
|
createOpprPlayerRanking: () => createOpprPlayerRanking,
|
|
51
43
|
createOpprRankingHistory: () => createOpprRankingHistory,
|
|
52
44
|
createPlayer: () => createPlayer,
|
|
53
|
-
createRound: () => createRound,
|
|
54
45
|
createStanding: () => createStanding,
|
|
55
46
|
createTournament: () => createTournament,
|
|
56
47
|
createUser: () => createUser,
|
|
@@ -58,16 +49,9 @@ __export(index_exports, {
|
|
|
58
49
|
deleteApiKey: () => deleteApiKey,
|
|
59
50
|
deleteBlogPost: () => deleteBlogPost,
|
|
60
51
|
deleteBlogTag: () => deleteBlogTag,
|
|
61
|
-
deleteEntriesByMatch: () => deleteEntriesByMatch,
|
|
62
|
-
deleteEntry: () => deleteEntry,
|
|
63
52
|
deleteLocation: () => deleteLocation,
|
|
64
|
-
deleteMatch: () => deleteMatch,
|
|
65
|
-
deleteMatchesByRound: () => deleteMatchesByRound,
|
|
66
|
-
deleteMatchesByTournament: () => deleteMatchesByTournament,
|
|
67
53
|
deleteOpprPlayerRanking: () => deleteOpprPlayerRanking,
|
|
68
54
|
deletePlayer: () => deletePlayer,
|
|
69
|
-
deleteRound: () => deleteRound,
|
|
70
|
-
deleteRoundsByTournament: () => deleteRoundsByTournament,
|
|
71
55
|
deleteStanding: () => deleteStanding,
|
|
72
56
|
deleteStandingsByTournament: () => deleteStandingsByTournament,
|
|
73
57
|
deleteTournament: () => deleteTournament,
|
|
@@ -82,14 +66,9 @@ __export(index_exports, {
|
|
|
82
66
|
findBlogTagById: () => findBlogTagById,
|
|
83
67
|
findBlogTagBySlug: () => findBlogTagBySlug,
|
|
84
68
|
findBlogTags: () => findBlogTags,
|
|
85
|
-
findEntries: () => findEntries,
|
|
86
|
-
findEntryById: () => findEntryById,
|
|
87
|
-
findEntryByMatchAndPlayer: () => findEntryByMatchAndPlayer,
|
|
88
69
|
findLocationByExternalId: () => findLocationByExternalId,
|
|
89
70
|
findLocationById: () => findLocationById,
|
|
90
71
|
findLocations: () => findLocations,
|
|
91
|
-
findMatchById: () => findMatchById,
|
|
92
|
-
findMatches: () => findMatches,
|
|
93
72
|
findOpprPlayerRankingById: () => findOpprPlayerRankingById,
|
|
94
73
|
findOpprPlayerRankingByPlayerId: () => findOpprPlayerRankingByPlayerId,
|
|
95
74
|
findOpprPlayerRankings: () => findOpprPlayerRankings,
|
|
@@ -99,9 +78,6 @@ __export(index_exports, {
|
|
|
99
78
|
findPlayerByUserEmail: () => findPlayerByUserEmail,
|
|
100
79
|
findPlayers: () => findPlayers,
|
|
101
80
|
findPublishedBlogPosts: () => findPublishedBlogPosts,
|
|
102
|
-
findRoundById: () => findRoundById,
|
|
103
|
-
findRoundByTournamentAndNumber: () => findRoundByTournamentAndNumber,
|
|
104
|
-
findRounds: () => findRounds,
|
|
105
81
|
findStandingById: () => findStandingById,
|
|
106
82
|
findStandingByPlayerAndTournament: () => findStandingByPlayerAndTournament,
|
|
107
83
|
findStandings: () => findStandings,
|
|
@@ -114,38 +90,25 @@ __export(index_exports, {
|
|
|
114
90
|
generateUniquePlayerNumber: () => generateUniquePlayerNumber,
|
|
115
91
|
getBlogTagWithPostCount: () => getBlogTagWithPostCount,
|
|
116
92
|
getBlogTagsWithPostCounts: () => getBlogTagsWithPostCounts,
|
|
117
|
-
getFinalsRounds: () => getFinalsRounds,
|
|
118
93
|
getFinalsStandings: () => getFinalsStandings,
|
|
119
94
|
getLatestOpprRankingHistory: () => getLatestOpprRankingHistory,
|
|
120
95
|
getLocationWithTournaments: () => getLocationWithTournaments,
|
|
121
96
|
getMajorTournaments: () => getMajorTournaments,
|
|
122
|
-
getMatchEntries: () => getMatchEntries,
|
|
123
|
-
getMatchWithEntries: () => getMatchWithEntries,
|
|
124
97
|
getMergedStandings: () => getMergedStandings,
|
|
125
98
|
getOpprRankingHistory: () => getOpprRankingHistory,
|
|
126
99
|
getOpprRankingHistoryByDateRange: () => getOpprRankingHistoryByDateRange,
|
|
127
100
|
getOrCreateOpprPlayerRanking: () => getOrCreateOpprPlayerRanking,
|
|
128
|
-
getPlayerEntries: () => getPlayerEntries,
|
|
129
|
-
getPlayerEntryStats: () => getPlayerEntryStats,
|
|
130
101
|
getPlayerStandings: () => getPlayerStandings,
|
|
131
102
|
getPlayerStats: () => getPlayerStats,
|
|
132
103
|
getPlayerTopFinishes: () => getPlayerTopFinishes,
|
|
133
|
-
getPlayerTournamentEntries: () => getPlayerTournamentEntries,
|
|
134
|
-
getPlayerTournamentMatches: () => getPlayerTournamentMatches,
|
|
135
104
|
getPlayerWithResults: () => getPlayerWithResults,
|
|
136
|
-
getQualifyingRounds: () => getQualifyingRounds,
|
|
137
105
|
getQualifyingStandings: () => getQualifyingStandings,
|
|
138
106
|
getRatedOpprPlayers: () => getRatedOpprPlayers,
|
|
139
107
|
getRecentTournaments: () => getRecentTournaments,
|
|
140
|
-
getRoundMatches: () => getRoundMatches,
|
|
141
|
-
getRoundWithMatches: () => getRoundWithMatches,
|
|
142
108
|
getTopPlayersByOpprRanking: () => getTopPlayersByOpprRanking,
|
|
143
109
|
getTopPlayersByOpprRating: () => getTopPlayersByOpprRating,
|
|
144
|
-
getTournamentMatches: () => getTournamentMatches,
|
|
145
|
-
getTournamentRounds: () => getTournamentRounds,
|
|
146
110
|
getTournamentStandings: () => getTournamentStandings,
|
|
147
111
|
getTournamentStats: () => getTournamentStats,
|
|
148
|
-
getTournamentWithMatches: () => getTournamentWithMatches,
|
|
149
112
|
getTournamentWithResults: () => getTournamentWithResults,
|
|
150
113
|
getTournamentsByBoosterType: () => getTournamentsByBoosterType,
|
|
151
114
|
getTournamentsByDateRange: () => getTournamentsByDateRange,
|
|
@@ -165,13 +128,10 @@ __export(index_exports, {
|
|
|
165
128
|
updateApiKeyLastUsed: () => updateApiKeyLastUsed,
|
|
166
129
|
updateBlogPost: () => updateBlogPost,
|
|
167
130
|
updateBlogTag: () => updateBlogTag,
|
|
168
|
-
updateEntry: () => updateEntry,
|
|
169
131
|
updateLocation: () => updateLocation,
|
|
170
|
-
updateMatch: () => updateMatch,
|
|
171
132
|
updateOpprPlayerRanking: () => updateOpprPlayerRanking,
|
|
172
133
|
updateOpprRatingAfterTournament: () => updateOpprRatingAfterTournament,
|
|
173
134
|
updatePlayer: () => updatePlayer,
|
|
174
|
-
updateRound: () => updateRound,
|
|
175
135
|
updateStanding: () => updateStanding,
|
|
176
136
|
updateStandingPoints: () => updateStandingPoints,
|
|
177
137
|
updateTournament: () => updateTournament,
|
|
@@ -617,28 +577,6 @@ async function getTournamentWithResults(id) {
|
|
|
617
577
|
}
|
|
618
578
|
});
|
|
619
579
|
}
|
|
620
|
-
async function getTournamentWithMatches(id) {
|
|
621
|
-
return prisma.tournament.findUnique({
|
|
622
|
-
where: { id },
|
|
623
|
-
include: {
|
|
624
|
-
rounds: {
|
|
625
|
-
include: {
|
|
626
|
-
matches: {
|
|
627
|
-
include: {
|
|
628
|
-
entries: {
|
|
629
|
-
include: {
|
|
630
|
-
player: true
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
|
-
orderBy: { number: "asc" }
|
|
635
|
-
}
|
|
636
|
-
},
|
|
637
|
-
orderBy: [{ isFinals: "asc" }, { number: "asc" }]
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
580
|
async function searchTournaments(query, limit = 20) {
|
|
643
581
|
return findTournaments({
|
|
644
582
|
take: limit,
|
|
@@ -680,323 +618,6 @@ async function getTournamentStats(id) {
|
|
|
680
618
|
};
|
|
681
619
|
}
|
|
682
620
|
|
|
683
|
-
// src/rounds.ts
|
|
684
|
-
async function createRound(data) {
|
|
685
|
-
return prisma.round.create({
|
|
686
|
-
data: {
|
|
687
|
-
...data,
|
|
688
|
-
isFinals: data.isFinals ?? false
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
async function createManyRounds(data) {
|
|
693
|
-
const roundsData = data.map((item) => ({
|
|
694
|
-
...item,
|
|
695
|
-
isFinals: item.isFinals ?? false
|
|
696
|
-
}));
|
|
697
|
-
return prisma.round.createMany({
|
|
698
|
-
data: roundsData
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
async function findRoundById(id, include) {
|
|
702
|
-
return prisma.round.findUnique({
|
|
703
|
-
where: { id },
|
|
704
|
-
include
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
async function findRoundByTournamentAndNumber(tournamentId, number, isFinals, include) {
|
|
708
|
-
return prisma.round.findUnique({
|
|
709
|
-
where: {
|
|
710
|
-
tournamentId_number_isFinals: {
|
|
711
|
-
tournamentId,
|
|
712
|
-
number,
|
|
713
|
-
isFinals
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
include
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
async function findRounds(options = {}) {
|
|
720
|
-
return prisma.round.findMany({
|
|
721
|
-
take: options.take,
|
|
722
|
-
skip: options.skip,
|
|
723
|
-
where: options.where,
|
|
724
|
-
orderBy: options.orderBy,
|
|
725
|
-
include: options.include
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
async function getTournamentRounds(tournamentId, options = {}) {
|
|
729
|
-
return findRounds({
|
|
730
|
-
...options,
|
|
731
|
-
where: { tournamentId },
|
|
732
|
-
orderBy: options.orderBy ?? [{ isFinals: "asc" }, { number: "asc" }]
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
async function getQualifyingRounds(tournamentId, options = {}) {
|
|
736
|
-
return findRounds({
|
|
737
|
-
...options,
|
|
738
|
-
where: { tournamentId, isFinals: false },
|
|
739
|
-
orderBy: options.orderBy ?? { number: "asc" }
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
async function getFinalsRounds(tournamentId, options = {}) {
|
|
743
|
-
return findRounds({
|
|
744
|
-
...options,
|
|
745
|
-
where: { tournamentId, isFinals: true },
|
|
746
|
-
orderBy: options.orderBy ?? { number: "asc" }
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
async function updateRound(id, data) {
|
|
750
|
-
return prisma.round.update({
|
|
751
|
-
where: { id },
|
|
752
|
-
data
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
async function deleteRound(id) {
|
|
756
|
-
return prisma.round.delete({
|
|
757
|
-
where: { id }
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
async function deleteRoundsByTournament(tournamentId) {
|
|
761
|
-
return prisma.round.deleteMany({
|
|
762
|
-
where: { tournamentId }
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
async function countRounds(where) {
|
|
766
|
-
return prisma.round.count({ where });
|
|
767
|
-
}
|
|
768
|
-
async function getRoundWithMatches(id) {
|
|
769
|
-
return prisma.round.findUnique({
|
|
770
|
-
where: { id },
|
|
771
|
-
include: {
|
|
772
|
-
matches: {
|
|
773
|
-
include: {
|
|
774
|
-
entries: {
|
|
775
|
-
include: {
|
|
776
|
-
player: true
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
},
|
|
780
|
-
orderBy: {
|
|
781
|
-
number: "asc"
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// src/matches.ts
|
|
789
|
-
async function createMatch(data) {
|
|
790
|
-
return prisma.match.create({
|
|
791
|
-
data
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
async function createManyMatches(data) {
|
|
795
|
-
return prisma.match.createMany({
|
|
796
|
-
data
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
async function findMatchById(id, include) {
|
|
800
|
-
return prisma.match.findUnique({
|
|
801
|
-
where: { id },
|
|
802
|
-
include
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
async function findMatches(options = {}) {
|
|
806
|
-
return prisma.match.findMany({
|
|
807
|
-
take: options.take,
|
|
808
|
-
skip: options.skip,
|
|
809
|
-
where: options.where,
|
|
810
|
-
orderBy: options.orderBy,
|
|
811
|
-
include: options.include
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
async function getTournamentMatches(tournamentId, options = {}) {
|
|
815
|
-
return findMatches({
|
|
816
|
-
...options,
|
|
817
|
-
where: { tournamentId },
|
|
818
|
-
orderBy: options.orderBy ?? { number: "asc" }
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
async function getRoundMatches(roundId, options = {}) {
|
|
822
|
-
return findMatches({
|
|
823
|
-
...options,
|
|
824
|
-
where: { roundId },
|
|
825
|
-
orderBy: options.orderBy ?? { number: "asc" }
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
async function updateMatch(id, data) {
|
|
829
|
-
return prisma.match.update({
|
|
830
|
-
where: { id },
|
|
831
|
-
data
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
async function deleteMatch(id) {
|
|
835
|
-
return prisma.match.delete({
|
|
836
|
-
where: { id }
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
async function deleteMatchesByTournament(tournamentId) {
|
|
840
|
-
return prisma.match.deleteMany({
|
|
841
|
-
where: { tournamentId }
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
async function deleteMatchesByRound(roundId) {
|
|
845
|
-
return prisma.match.deleteMany({
|
|
846
|
-
where: { roundId }
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
async function countMatches(where) {
|
|
850
|
-
return prisma.match.count({ where });
|
|
851
|
-
}
|
|
852
|
-
async function getMatchWithEntries(id) {
|
|
853
|
-
return prisma.match.findUnique({
|
|
854
|
-
where: { id },
|
|
855
|
-
include: {
|
|
856
|
-
entries: {
|
|
857
|
-
include: {
|
|
858
|
-
player: true
|
|
859
|
-
},
|
|
860
|
-
orderBy: {
|
|
861
|
-
position: "asc"
|
|
862
|
-
}
|
|
863
|
-
},
|
|
864
|
-
round: true
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
async function getPlayerTournamentMatches(playerId, tournamentId, include) {
|
|
869
|
-
return findMatches({
|
|
870
|
-
where: {
|
|
871
|
-
tournamentId,
|
|
872
|
-
entries: {
|
|
873
|
-
some: {
|
|
874
|
-
playerId
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
},
|
|
878
|
-
include: include ?? {
|
|
879
|
-
entries: {
|
|
880
|
-
include: {
|
|
881
|
-
player: true
|
|
882
|
-
}
|
|
883
|
-
},
|
|
884
|
-
round: true
|
|
885
|
-
},
|
|
886
|
-
orderBy: [{ round: { number: "asc" } }, { number: "asc" }]
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
// src/entries.ts
|
|
891
|
-
async function createEntry(data) {
|
|
892
|
-
return prisma.entry.create({
|
|
893
|
-
data
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
async function createManyEntries(data) {
|
|
897
|
-
return prisma.entry.createMany({
|
|
898
|
-
data
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
async function findEntryById(id, include) {
|
|
902
|
-
return prisma.entry.findUnique({
|
|
903
|
-
where: { id },
|
|
904
|
-
include
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
async function findEntryByMatchAndPlayer(matchId, playerId, include) {
|
|
908
|
-
return prisma.entry.findUnique({
|
|
909
|
-
where: {
|
|
910
|
-
matchId_playerId: {
|
|
911
|
-
matchId,
|
|
912
|
-
playerId
|
|
913
|
-
}
|
|
914
|
-
},
|
|
915
|
-
include
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
async function findEntries(options = {}) {
|
|
919
|
-
return prisma.entry.findMany({
|
|
920
|
-
take: options.take,
|
|
921
|
-
skip: options.skip,
|
|
922
|
-
where: options.where,
|
|
923
|
-
orderBy: options.orderBy,
|
|
924
|
-
include: options.include
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
async function getMatchEntries(matchId, options = {}) {
|
|
928
|
-
return findEntries({
|
|
929
|
-
...options,
|
|
930
|
-
where: { matchId },
|
|
931
|
-
include: options.include ?? { player: true },
|
|
932
|
-
orderBy: options.orderBy ?? { position: "asc" }
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
async function getPlayerEntries(playerId, options = {}) {
|
|
936
|
-
return findEntries({
|
|
937
|
-
...options,
|
|
938
|
-
where: { playerId },
|
|
939
|
-
include: options.include ?? { match: { include: { round: true, tournament: true } } }
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
async function getPlayerTournamentEntries(playerId, tournamentId, include) {
|
|
943
|
-
return findEntries({
|
|
944
|
-
where: {
|
|
945
|
-
playerId,
|
|
946
|
-
match: {
|
|
947
|
-
tournamentId
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
include: include ?? {
|
|
951
|
-
match: {
|
|
952
|
-
include: {
|
|
953
|
-
round: true,
|
|
954
|
-
entries: {
|
|
955
|
-
include: {
|
|
956
|
-
player: true
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
async function updateEntry(id, data) {
|
|
965
|
-
return prisma.entry.update({
|
|
966
|
-
where: { id },
|
|
967
|
-
data
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
async function deleteEntry(id) {
|
|
971
|
-
return prisma.entry.delete({
|
|
972
|
-
where: { id }
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
async function deleteEntriesByMatch(matchId) {
|
|
976
|
-
return prisma.entry.deleteMany({
|
|
977
|
-
where: { matchId }
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
async function countEntries(where) {
|
|
981
|
-
return prisma.entry.count({ where });
|
|
982
|
-
}
|
|
983
|
-
async function getPlayerEntryStats(playerId) {
|
|
984
|
-
const entries = await getPlayerEntries(playerId);
|
|
985
|
-
if (entries.length === 0) {
|
|
986
|
-
return null;
|
|
987
|
-
}
|
|
988
|
-
const wins = entries.filter((e) => e.result === "WIN").length;
|
|
989
|
-
const losses = entries.filter((e) => e.result === "LOSS").length;
|
|
990
|
-
const ties = entries.filter((e) => e.result === "TIE").length;
|
|
991
|
-
return {
|
|
992
|
-
totalMatches: entries.length,
|
|
993
|
-
wins,
|
|
994
|
-
losses,
|
|
995
|
-
ties,
|
|
996
|
-
winRate: wins / entries.length
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
621
|
// src/standings.ts
|
|
1001
622
|
async function createStanding(data) {
|
|
1002
623
|
const standingData = {
|
|
@@ -1680,14 +1301,11 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1680
1301
|
connect,
|
|
1681
1302
|
countBlogPosts,
|
|
1682
1303
|
countBlogTags,
|
|
1683
|
-
countEntries,
|
|
1684
1304
|
countLocations,
|
|
1685
|
-
countMatches,
|
|
1686
1305
|
countOpprPlayerRankings,
|
|
1687
1306
|
countOpprRankingHistory,
|
|
1688
1307
|
countPlayers,
|
|
1689
1308
|
countPublishedBlogPosts,
|
|
1690
|
-
countRounds,
|
|
1691
1309
|
countStandings,
|
|
1692
1310
|
countTournaments,
|
|
1693
1311
|
countUserApiKeys,
|
|
@@ -1695,17 +1313,11 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1695
1313
|
createApiKey,
|
|
1696
1314
|
createBlogPost,
|
|
1697
1315
|
createBlogTag,
|
|
1698
|
-
createEntry,
|
|
1699
1316
|
createLocation,
|
|
1700
|
-
createManyEntries,
|
|
1701
|
-
createManyMatches,
|
|
1702
|
-
createManyRounds,
|
|
1703
1317
|
createManyStandings,
|
|
1704
|
-
createMatch,
|
|
1705
1318
|
createOpprPlayerRanking,
|
|
1706
1319
|
createOpprRankingHistory,
|
|
1707
1320
|
createPlayer,
|
|
1708
|
-
createRound,
|
|
1709
1321
|
createStanding,
|
|
1710
1322
|
createTournament,
|
|
1711
1323
|
createUser,
|
|
@@ -1713,16 +1325,9 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1713
1325
|
deleteApiKey,
|
|
1714
1326
|
deleteBlogPost,
|
|
1715
1327
|
deleteBlogTag,
|
|
1716
|
-
deleteEntriesByMatch,
|
|
1717
|
-
deleteEntry,
|
|
1718
1328
|
deleteLocation,
|
|
1719
|
-
deleteMatch,
|
|
1720
|
-
deleteMatchesByRound,
|
|
1721
|
-
deleteMatchesByTournament,
|
|
1722
1329
|
deleteOpprPlayerRanking,
|
|
1723
1330
|
deletePlayer,
|
|
1724
|
-
deleteRound,
|
|
1725
|
-
deleteRoundsByTournament,
|
|
1726
1331
|
deleteStanding,
|
|
1727
1332
|
deleteStandingsByTournament,
|
|
1728
1333
|
deleteTournament,
|
|
@@ -1737,14 +1342,9 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1737
1342
|
findBlogTagById,
|
|
1738
1343
|
findBlogTagBySlug,
|
|
1739
1344
|
findBlogTags,
|
|
1740
|
-
findEntries,
|
|
1741
|
-
findEntryById,
|
|
1742
|
-
findEntryByMatchAndPlayer,
|
|
1743
1345
|
findLocationByExternalId,
|
|
1744
1346
|
findLocationById,
|
|
1745
1347
|
findLocations,
|
|
1746
|
-
findMatchById,
|
|
1747
|
-
findMatches,
|
|
1748
1348
|
findOpprPlayerRankingById,
|
|
1749
1349
|
findOpprPlayerRankingByPlayerId,
|
|
1750
1350
|
findOpprPlayerRankings,
|
|
@@ -1754,9 +1354,6 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1754
1354
|
findPlayerByUserEmail,
|
|
1755
1355
|
findPlayers,
|
|
1756
1356
|
findPublishedBlogPosts,
|
|
1757
|
-
findRoundById,
|
|
1758
|
-
findRoundByTournamentAndNumber,
|
|
1759
|
-
findRounds,
|
|
1760
1357
|
findStandingById,
|
|
1761
1358
|
findStandingByPlayerAndTournament,
|
|
1762
1359
|
findStandings,
|
|
@@ -1769,38 +1366,25 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1769
1366
|
generateUniquePlayerNumber,
|
|
1770
1367
|
getBlogTagWithPostCount,
|
|
1771
1368
|
getBlogTagsWithPostCounts,
|
|
1772
|
-
getFinalsRounds,
|
|
1773
1369
|
getFinalsStandings,
|
|
1774
1370
|
getLatestOpprRankingHistory,
|
|
1775
1371
|
getLocationWithTournaments,
|
|
1776
1372
|
getMajorTournaments,
|
|
1777
|
-
getMatchEntries,
|
|
1778
|
-
getMatchWithEntries,
|
|
1779
1373
|
getMergedStandings,
|
|
1780
1374
|
getOpprRankingHistory,
|
|
1781
1375
|
getOpprRankingHistoryByDateRange,
|
|
1782
1376
|
getOrCreateOpprPlayerRanking,
|
|
1783
|
-
getPlayerEntries,
|
|
1784
|
-
getPlayerEntryStats,
|
|
1785
1377
|
getPlayerStandings,
|
|
1786
1378
|
getPlayerStats,
|
|
1787
1379
|
getPlayerTopFinishes,
|
|
1788
|
-
getPlayerTournamentEntries,
|
|
1789
|
-
getPlayerTournamentMatches,
|
|
1790
1380
|
getPlayerWithResults,
|
|
1791
|
-
getQualifyingRounds,
|
|
1792
1381
|
getQualifyingStandings,
|
|
1793
1382
|
getRatedOpprPlayers,
|
|
1794
1383
|
getRecentTournaments,
|
|
1795
|
-
getRoundMatches,
|
|
1796
|
-
getRoundWithMatches,
|
|
1797
1384
|
getTopPlayersByOpprRanking,
|
|
1798
1385
|
getTopPlayersByOpprRating,
|
|
1799
|
-
getTournamentMatches,
|
|
1800
|
-
getTournamentRounds,
|
|
1801
1386
|
getTournamentStandings,
|
|
1802
1387
|
getTournamentStats,
|
|
1803
|
-
getTournamentWithMatches,
|
|
1804
1388
|
getTournamentWithResults,
|
|
1805
1389
|
getTournamentsByBoosterType,
|
|
1806
1390
|
getTournamentsByDateRange,
|
|
@@ -1820,13 +1404,10 @@ async function getBlogTagsWithPostCounts() {
|
|
|
1820
1404
|
updateApiKeyLastUsed,
|
|
1821
1405
|
updateBlogPost,
|
|
1822
1406
|
updateBlogTag,
|
|
1823
|
-
updateEntry,
|
|
1824
1407
|
updateLocation,
|
|
1825
|
-
updateMatch,
|
|
1826
1408
|
updateOpprPlayerRanking,
|
|
1827
1409
|
updateOpprRatingAfterTournament,
|
|
1828
1410
|
updatePlayer,
|
|
1829
|
-
updateRound,
|
|
1830
1411
|
updateStanding,
|
|
1831
1412
|
updateStandingPoints,
|
|
1832
1413
|
updateTournament,
|