11-- name: GetChallengesByIDs :many
2- SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at
2+ SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at
33FROM challenges
44WHERE id = ANY(@ids::text []);
55
66-- name: GetChallengesByProjectIDs :many
7- SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at
7+ SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at
88FROM challenges
99WHERE project_id = ANY(@project_ids::text [])
1010 AND published_at IS NOT NULL
1111 AND published_at <= NOW()
1212ORDER BY project_id, published_at DESC ;
1313
1414-- name: GetChallengesByEventIDs :many
15- SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at
15+ SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at
1616FROM challenges
1717WHERE event_id = ANY(@event_ids::text [])
1818 AND published_at IS NOT NULL
1919 AND published_at <= NOW()
2020ORDER BY event_id, published_at DESC ;
2121
2222-- name: GetChallengesFilteredCursor :many
23- SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at
23+ SELECT id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at
2424FROM challenges
2525WHERE
2626 (@ids::text [] IS NULL OR id = ANY(@ids::text []))
@@ -56,7 +56,10 @@ INSERT INTO challenges (
5656 url,
5757 button_text,
5858 published_at,
59- end_time
59+ visible_at,
60+ end_time,
61+ requires_team_membership,
62+ requires_super_team_membership
6063)
6164VALUES (
6265 @id::text ,
@@ -68,9 +71,12 @@ VALUES (
6871 sqlc .narg (' url' )::text ,
6972 @buttontext::text ,
7073 @publishedat::timestamptz ,
71- @endtime::timestamptz
74+ sqlc .narg (' visibleat' )::timestamptz ,
75+ @endtime::timestamptz ,
76+ COALESCE(sqlc .narg (' requiresteammembership' )::bool, false),
77+ COALESCE(sqlc .narg (' requiressuperteammembership' )::bool, false)
7278)
73- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
79+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at;
7480
7581-- name: UpdateChallenge :one
7682UPDATE challenges
8187 url = COALESCE(sqlc .narg (' url' )::text , url),
8288 button_text = COALESCE(sqlc .narg (' buttontext' )::text , button_text),
8389 event_id = COALESCE(sqlc .narg (' eventid' )::text , event_id),
90+ visible_at = COALESCE(sqlc .narg (' visibleat' )::timestamptz , visible_at),
91+ started_at = COALESCE(sqlc .narg (' startedat' )::timestamptz , started_at),
8492 end_time = COALESCE(sqlc .narg (' endtime' )::timestamptz , end_time),
93+ requires_team_membership = COALESCE(sqlc .narg (' requiresteammembership' )::bool, requires_team_membership),
94+ requires_super_team_membership = COALESCE(sqlc .narg (' requiressuperteammembership' )::bool, requires_super_team_membership),
8595 updated_at = now()
8696WHERE id = @id::text
87- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
97+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at;
8898
8999-- name: DeleteChallenge :exec
90100DELETE FROM challenges
96106 published_at = @publishedat::timestamptz ,
97107 updated_at = now()
98108WHERE id = @id::text
99- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
109+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at;
100110
101111-- name: AssignChallengeToEvent :one
102112UPDATE challenges
103113SET
104114 event_id = @eventid::text ,
105115 updated_at = now()
106116WHERE id = @id::text
107- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
117+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at;
108118
109119-- name: BulkPublishChallenges :many
110120UPDATE challenges
111121SET
112122 published_at = @publishedat::timestamptz ,
113123 updated_at = now()
114124WHERE id = ANY(@ids::text [])
115- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
125+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership , created_at, updated_at;
116126
117127-- name: BulkCreateChallenges :many
118128INSERT INTO challenges (
@@ -125,7 +135,10 @@ INSERT INTO challenges (
125135 url,
126136 button_text,
127137 published_at,
128- end_time
138+ visible_at,
139+ end_time,
140+ requires_team_membership,
141+ requires_super_team_membership
129142)
130143SELECT
131144 unnest(@ids::text []),
@@ -137,5 +150,26 @@ SELECT
137150 unnest(@urls::text []),
138151 unnest(@buttontexts::text []),
139152 unnest(@publishedats::timestamptz []),
140- unnest(@endtimes::timestamptz [])
141- RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, end_time, created_at, updated_at;
153+ unnest(@visibleats::timestamptz []),
154+ unnest(@endtimes::timestamptz []),
155+ unnest(@requiresteammemberships::bool[]),
156+ unnest(@requiressuperteammemberships::bool[])
157+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership, created_at, updated_at;
158+
159+ -- name: UpdateChallengeTimestamps :one
160+ UPDATE challenges
161+ SET
162+ visible_at = COALESCE(sqlc .narg (' visibleat' )::timestamptz , visible_at),
163+ started_at = COALESCE(sqlc .narg (' startedat' )::timestamptz , started_at),
164+ updated_at = now()
165+ WHERE id = @id::text
166+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership, created_at, updated_at;
167+
168+ -- name: UpdateChallengeRequirements :one
169+ UPDATE challenges
170+ SET
171+ requires_team_membership = COALESCE(sqlc .narg (' requiresteammembership' )::bool, requires_team_membership),
172+ requires_super_team_membership = COALESCE(sqlc .narg (' requiressuperteammembership' )::bool, requires_super_team_membership),
173+ updated_at = now()
174+ WHERE id = @id::text
175+ RETURNING id, project_id, event_id, name, description, image_url, url, button_text, published_at, visible_at, started_at, end_time, requires_team_membership, requires_super_team_membership, created_at, updated_at;
0 commit comments