-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfindFeaturedEvents.ts
More file actions
41 lines (38 loc) · 2.65 KB
/
findFeaturedEvents.ts
File metadata and controls
41 lines (38 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
// @ts-nocheck
import * as $runtime from "@prisma/client/runtime/client"
import { type $DbEnums } from "./$DbEnums"
/**
* @param offset
* @param limit
*/
export const findFeaturedEvents = $runtime.makeTypedQueryFactory("\n\n\n\nWITH\ncapacities AS (\nSELECT\nattendance_id,\nSUM(\"capacity\") AS sum\nFROM attendance_pool\nGROUP BY attendance_id\n),\n\nattendees AS (\nSELECT\nattendance_id,\nCOUNT(*) AS count\nFROM attendee\nGROUP BY attendance_id\n)\n\nSELECT\nevent.*,\nCOALESCE(capacities.sum, 0) AS total_capacity,\nCOALESCE(attendees.count, 0) AS attendee_count,\n\nCASE event.\"type\"\nWHEN 'GENERAL_ASSEMBLY' THEN 1\nWHEN 'COMPANY' THEN 2\nWHEN 'ACADEMIC' THEN 2\nELSE 3\nEND AS type_rank,\n\nCASE\nWHEN event.attendance_id IS NOT NULL\nAND NOW() BETWEEN attendance.register_start AND attendance.register_end\nAND COALESCE(capacities.sum, 0) > 0\nAND COALESCE(attendees.count, 0) < COALESCE(capacities.sum, 0)\nTHEN 1\n\nWHEN event.attendance_id IS NOT NULL\nAND NOW() < attendance.register_start\nTHEN 2\n\nWHEN event.attendance_id IS NULL\nOR COALESCE(capacities.sum, 0) = 0\nTHEN 3\n\nWHEN event.attendance_id IS NOT NULL\nAND COALESCE(capacities.sum, 0) > 0\nAND COALESCE(attendees.count, 0) >= COALESCE(capacities.sum, 0)\nTHEN 4\n\nELSE 4\nEND AS registration_bucket\n\nFROM event\nLEFT JOIN \"attendance\"\nON \"attendance\".\"id\" = event.attendance_id\nLEFT JOIN capacities\nON capacities.attendance_id = event.attendance_id\nLEFT JOIN attendees\nON attendees.attendance_id = event.attendance_id\n\nWHERE\nevent.status = 'PUBLIC'\nAND event.start > NOW()\n\nORDER BY\ntype_rank ASC,\nregistration_bucket ASC,\nevent.\"start\" ASC\n\nOFFSET $1\nLIMIT $2;") as (offset: number, limit: number) => $runtime.TypedSql<findFeaturedEvents.Parameters, findFeaturedEvents.Result>
export namespace findFeaturedEvents {
export type Parameters = [offset: number, limit: number]
export type Result = {
id: string
title: string
start: Date
end: Date
status: $DbEnums["event_status"]
description: string
short_description: string | null
image_url: string | null
location_title: string | null
location_address: string | null
location_link: string | null
attendance_id: string | null
type: $DbEnums["event_type"]
created_at: Date
updated_at: Date
metadata_import_id: number | null
parent_id: string | null
mark_for_missed_attendance: boolean
total_capacity: bigint | null
attendee_count: bigint | null
type_rank: number | null
registration_bucket: number | null
}
}