-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
159 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/features/sendouq/queries/findRecentMatchPlayersByUserId.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { sql } from "~/db/sql"; | ||
import type { GroupMember } from "~/db/types"; | ||
|
||
const stm = sql.prepare(/* sql*/ ` | ||
with "MostRecentGroupMatch" as ( | ||
select | ||
"GroupMatch".* | ||
from "GroupMember" | ||
left join "Group" on "Group"."id" = "GroupMember"."groupId" | ||
inner join "GroupMatch" on "GroupMatch"."alphaGroupId" = "Group"."id" | ||
or "GroupMatch"."bravoGroupId" = "Group"."id" | ||
where | ||
"GroupMember"."userId" = @userId | ||
order by "GroupMatch"."createdAt" desc | ||
limit 1 | ||
) | ||
select | ||
"GroupMember"."groupId", | ||
"GroupMember"."userId" | ||
from "MostRecentGroupMatch" | ||
left join "Group" on "Group"."id" = "MostRecentGroupMatch"."alphaGroupId" | ||
or "Group"."id" = "MostRecentGroupMatch"."bravoGroupId" | ||
left join "GroupMember" on "GroupMember"."groupId" = "Group"."id" | ||
where | ||
"MostRecentGroupMatch"."createdAt" > unixepoch() - 60 * 60 * 2 | ||
`); | ||
|
||
export type RecentMatchPlayer = Pick<GroupMember, "groupId" | "userId">; | ||
|
||
export function findRecentMatchPlayersByUserId(userId: number) { | ||
return stm.all({ userId }) as Array<RecentMatchPlayer>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters