File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import { GameCategory, PageVersion } from "@prisma/client";
33import db from "../../infra/db.js" ;
44import { materializeGamePage } from "../games/page.helpers.js" ;
55import {
6- ODA_GAME_CATEGORY ,
76 OVERALL_RATING_CATEGORY_NAME ,
87 REGULAR_GAME_CATEGORY ,
8+ isAllowedJamRater ,
99} from "../games/policies.js" ;
1010
1111type ResultCategory = {
@@ -49,6 +49,25 @@ function ratingBelongsToResultVersion(
4949 : ratingVersion === version ;
5050}
5151
52+ function isAllowedResultRater (
53+ rating : {
54+ user : {
55+ teams : Array < {
56+ game : {
57+ published : boolean ;
58+ jamId ?: number | null ;
59+ category ?: GameCategory | null ;
60+ } | null ;
61+ } > ;
62+ } ;
63+ } ,
64+ jamId : number ,
65+ ) {
66+ return rating . user . teams . some ( ( team ) => {
67+ return isAllowedJamRater ( team . game , jamId ) ;
68+ } ) ;
69+ }
70+
5271function gameSortCategoryName ( sort ?: string ) {
5372 switch ( sort ) {
5473 case "GAMEPLAY" :
@@ -210,6 +229,8 @@ export async function loadGameResults({
210229 game : {
211230 select : {
212231 published : true ,
232+ jamId : true ,
233+ category : true ,
213234 } ,
214235 } ,
215236 } ,
@@ -268,7 +289,7 @@ export async function loadGameResults({
268289 const categoryRatings = filteredRatings . filter (
269290 ( rating ) =>
270291 rating . categoryId === ratingCategory . id &&
271- rating . user . teams . filter ( ( team ) => team . game ?. published ) . length > 0 ,
292+ isAllowedResultRater ( rating , game . jamId ) ,
272293 ) ;
273294
274295 const averageScore =
You can’t perform that action at this time.
0 commit comments