@@ -217,24 +217,6 @@ public static function regenerateHash(string $password_hash): bool {
217217 }
218218 }
219219
220- // Check to see if the team is active.
221- public static async function genCheckTeamStatus (
222- int $team_id ,
223- ): Awaitable <bool > {
224- $db = await self :: genDb();
225- $result = await $db -> queryf(
226- ' SELECT COUNT (* ) FROM teams WHERE id = %d AND active = 1 LIMIT 1 ' ,
227- $team_id ,
228- );
229-
230- if ($result -> numRows() > 0 ) {
231- invariant ($result -> numRows() === 1 , ' Expected exactly one result' );
232- return (intval (idx ($result -> mapRows()[0 ], ' COUNT(*)' )) > 0 );
233- } else {
234- return false ;
235- }
236- }
237-
238220 // Create a team and return the created team id.
239221 public static async function genCreate (
240222 string $name ,
@@ -542,30 +524,13 @@ public static function regenerateHash(string $password_hash): bool {
542524 $db = await self :: genDb();
543525
544526 $result = await $db -> queryf(
545- ' SELECT COUNT ( * ) FROM teams WHERE name = %s' ,
527+ ' SELECT EXISTS( SELECT * FROM teams WHERE name = %s) ' ,
546528 $team_name ,
547529 );
548530
549531 if ($result -> numRows() > 0 ) {
550532 invariant ($result -> numRows() === 1 , ' Expected exactly one result' );
551- return (intval (idx ($result -> mapRows()[0 ], ' COUNT(*)' )) > 0 );
552- } else {
553- return false ;
554- }
555- }
556-
557- // Check if a team name is already created.
558- public static async function genTeamExistById (
559- int $team_id ,
560- ): Awaitable <bool > {
561- $db = await self :: genDb();
562-
563- $result =
564- await $db -> queryf(' SELECT COUNT (* ) FROM teams WHERE id = %d' , $team_id );
565-
566- if ($result -> numRows() > 0 ) {
567- invariant ($result -> numRows() === 1 , ' Expected exactly one result' );
568- return (intval (idx ($result -> mapRows()[0 ], ' COUNT(*)' )) > 0 );
533+ return intval ($result -> mapRows()[0 ]-> firstValue()) > 0 ;
569534 } else {
570535 return false ;
571536 }
@@ -717,16 +682,6 @@ public static function regenerateHash(string $password_hash): bool {
717682 MultiTeam :: invalidateMCRecords(); // Invalidate Memcached MultiTeam data.
718683 }
719684
720- // Teams total number.
721- public static async function genTeamsCount (): Awaitable <int > {
722- $db = await self :: genDb();
723-
724- $result = await $db -> queryf(' SELECT COUNT (* ) AS count FROM teams' );
725-
726- invariant ($result -> numRows() === 1 , ' Expected exactly one result' );
727- return intval (idx ($result -> mapRows()[0 ], ' COUNT(*)' ));
728- }
729-
730685 public static async function genFirstCapture (
731686 int $level_id ,
732687 ): Awaitable <Team > {
0 commit comments