@@ -1582,6 +1582,55 @@ export const get_team_software_final_submission_count: any = async (
15821582 ) ;
15831583} ;
15841584
1585+ export const add_team_RL_code : any = async (
1586+ team_id : string ,
1587+ code_url : string ,
1588+ ) => {
1589+ const insert_team_RL_code : any = await client . request (
1590+ gql `
1591+ mutation add_team_RL_code($team_id: uuid!, $url: String!) {
1592+ insert_contest_team_RL_code_one(
1593+ object: { team_id: $team_id, url: $url }
1594+ ) {
1595+ submit_id
1596+ team_id
1597+ created_at
1598+ url
1599+ }
1600+ }
1601+ ` ,
1602+ {
1603+ team_id : team_id ,
1604+ url : code_url ,
1605+ } ,
1606+ ) ;
1607+
1608+ return insert_team_RL_code . insert_contest_team_RL_code_one ;
1609+ } ;
1610+
1611+ export const get_team_RL_code_submissions : any = async ( team_id : string ) => {
1612+ const query_team_RL_code_submissions : any = await client . request (
1613+ gql `
1614+ query get_team_RL_code_submissions($team_id: uuid!) {
1615+ contest_team_RL_code(
1616+ where: { team_id: { _eq: $team_id } }
1617+ order_by: { created_at: asc }
1618+ ) {
1619+ submit_id
1620+ team_id
1621+ created_at
1622+ url
1623+ }
1624+ }
1625+ ` ,
1626+ {
1627+ team_id : team_id ,
1628+ } ,
1629+ ) ;
1630+
1631+ return query_team_RL_code_submissions . contest_team_RL_code ;
1632+ } ;
1633+
15851634/**
15861635 *
15871636 * @param {uuid } contest_id ID
@@ -2713,6 +2762,37 @@ export const get_software_contest_deadline: any = async (
27132762 ) ;
27142763} ;
27152764
2765+ export const set_software_contest_deadline : any = async (
2766+ contest_id : string ,
2767+ deadline : string ,
2768+ ) => {
2769+ const upsert_software_contest_deadline : any = await client . request (
2770+ gql `
2771+ mutation set_software_contest_deadline(
2772+ $contest_id: uuid!
2773+ $deadline: timestamptz!
2774+ ) {
2775+ insert_contest_soft_code_deadline_one(
2776+ object: { contest_id: $contest_id, deadline: $deadline }
2777+ on_conflict: {
2778+ constraint: contest_soft_code_deadline_pkey
2779+ update_columns: [deadline]
2780+ }
2781+ ) {
2782+ contest_id
2783+ deadline
2784+ }
2785+ }
2786+ ` ,
2787+ {
2788+ contest_id : contest_id ,
2789+ deadline : deadline ,
2790+ } ,
2791+ ) ;
2792+
2793+ return upsert_software_contest_deadline . insert_contest_soft_code_deadline_one ;
2794+ } ;
2795+
27162796export const get_contest_id_from_team_id : any = async ( team_id : string ) => {
27172797 const query_contest_id_from_team_id : any = await client . request (
27182798 gql `
@@ -2728,3 +2808,58 @@ export const get_contest_id_from_team_id: any = async (team_id: string) => {
27282808 ) ;
27292809 return query_contest_id_from_team_id . contest_team [ 0 ] ?. contest_id ?? undefined ;
27302810} ;
2811+
2812+ /**
2813+ * Get all RL scores for a contest, ordered by score descending.
2814+ * @param {string } contest_id
2815+ * @returns {Array<{team_id, score, team_name}> }
2816+ */
2817+ export const get_all_RL_scores : any = async ( contest_id : string ) => {
2818+ const result : any = await client . request (
2819+ gql `
2820+ query GetAllRLScores($contest_id: uuid!) {
2821+ contest_team_RL_score(
2822+ where: { contest_team: { contest_id: { _eq: $contest_id } } }
2823+ order_by: { score: desc_nulls_last }
2824+ ) {
2825+ team_id
2826+ score
2827+ contest_team {
2828+ team_name
2829+ }
2830+ }
2831+ }
2832+ ` ,
2833+ { contest_id } ,
2834+ ) ;
2835+ return result . contest_team_RL_score ?? [ ] ;
2836+ } ;
2837+
2838+ /**
2839+ * Upsert (insert or update) a team's RL score.
2840+ * @param {string } team_id
2841+ * @param {number } score
2842+ * @returns {string } team_id
2843+ */
2844+ export const upsert_team_RL_score : any = async (
2845+ team_id : string ,
2846+ score : number ,
2847+ ) => {
2848+ const result : any = await client . request (
2849+ gql `
2850+ mutation UpsertTeamRLScore($team_id: uuid!, $score: Int!) {
2851+ insert_contest_team_RL_score_one(
2852+ object: { team_id: $team_id, score: $score }
2853+ on_conflict: {
2854+ constraint: contest_team_RL_score_pkey
2855+ update_columns: [score]
2856+ }
2857+ ) {
2858+ team_id
2859+ }
2860+ }
2861+ ` ,
2862+ { team_id, score } ,
2863+ ) ;
2864+ return result . insert_contest_team_RL_score_one ?. team_id ?? undefined ;
2865+ } ;
0 commit comments