Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
49cb853
chore: remove avatars in admin
sifferhans Jan 6, 2026
81cab95
wip: start work on churc hadmin page
sifferhans Jan 6, 2026
9aa8b43
wip: make church admins have only my-access
sifferhans Jan 6, 2026
e710cbd
fix: make sure church admins have restricted access
sifferhans Jan 6, 2026
dea9818
wip: church
sifferhans Jan 6, 2026
7f760c7
wip: teams admin
sifferhans Jan 7, 2026
dd8eebf
wip: improved layout
sifferhans Jan 7, 2026
8df924a
feat(admin): bulk create units
sifferhans Jan 12, 2026
4073b93
feat(admin): bulk delete
sifferhans Jan 12, 2026
7a934d0
feat(admin): search for people in units + expand all
sifferhans Jan 12, 2026
489a823
wip(admin): drag and drop
sifferhans Jan 12, 2026
3d9a729
chore: center text in admin unit card
sifferhans Jan 12, 2026
a353301
feat: drag and drop
sifferhans Jan 12, 2026
a007cce
fix: optimistic UI for drag and drop
sifferhans Jan 12, 2026
6001906
feat(admin): optimistic UI
sifferhans Jan 12, 2026
654b8cb
feat(admin): show gender in units page
sifferhans Jan 12, 2026
02c6e88
feat: church name random unit name
sifferhans Jan 12, 2026
67f5c41
feaet(admin): make unit leader
sifferhans Jan 12, 2026
2194447
feat(admin): team lead design change
sifferhans Jan 12, 2026
2cb12ed
feat(admin): use gender icons
sifferhans Jan 12, 2026
759ef20
fix(admin): hide leader button if not hovering
sifferhans Jan 12, 2026
dee42fc
feat(admin): start localizing
sifferhans Jan 13, 2026
1d9fc84
feat(admin): o36 filter
sifferhans Jan 13, 2026
e660265
feat(admin): o36 warnings
sifferhans Jan 13, 2026
465beb8
feat: close unit edit drawer
sifferhans Jan 13, 2026
ce8670c
fix: hide unit edit until kickoff
sifferhans Jan 13, 2026
61e2363
feat(admin): edit unit names
sifferhans Jan 13, 2026
1ef5f78
Merge branch 'main' into feature/church-admin
sifferhans Jan 13, 2026
6f70ebe
feat(admin): hide from leaderboards if exclude from leaderboards
sifferhans Jan 13, 2026
d065e1e
feat(admin): church admin register other church admins
sifferhans Jan 13, 2026
a862a4a
feat(admin): copy link to church admin
sifferhans Jan 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- +goose Up
ALTER TABLE teams
ADD COLUMN leaderboard_excluded BOOLEAN NOT NULL DEFAULT false;

CREATE INDEX idx_teams_leaderboard_excluded ON teams(leaderboard_excluded) WHERE leaderboard_excluded = true;

-- +goose Down
DROP INDEX IF EXISTS idx_teams_leaderboard_excluded;
ALTER TABLE teams DROP COLUMN IF EXISTS leaderboard_excluded;
10 changes: 9 additions & 1 deletion backend/internal/database/queries/leaderboards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ WITH team_scores AS (
LEFT JOIN score_journal sj ON sj.user_id = u.id AND sj.project_id = @projectid::text
WHERE
t.project_id = @projectid::text
AND t.leaderboard_excluded = false
AND (@superteamid::text = '' OR t.super_team_id = @superteamid::text)
GROUP BY t.id, t.name
),
Expand Down Expand Up @@ -226,6 +227,7 @@ WITH ranked_scores AS (
FROM leaderboard_project_teams lpt
INNER JOIN teams t ON lpt.team_id = t.id
WHERE lpt.project_id = @projectid::text
AND t.leaderboard_excluded = false
AND lpt.score >= COALESCE(@minscore::int, 1)
AND (@maxscore::int IS NULL OR lpt.score <= @maxscore::int)
),
Expand All @@ -251,6 +253,7 @@ WITH ranked_scores AS (
FROM leaderboard_project_teams lpt
INNER JOIN teams t ON lpt.team_id = t.id
WHERE lpt.project_id = @projectid::text
AND t.leaderboard_excluded = false
AND lpt.score >= COALESCE(@minscore::int, 1)
AND (@maxscore::int IS NULL OR lpt.score <= @maxscore::int)
)
Expand All @@ -263,6 +266,7 @@ SELECT COUNT(DISTINCT t.id)::bigint AS total
FROM teams t
WHERE
t.project_id = @projectid::text
AND t.leaderboard_excluded = false
AND (@superteamid::text = '' OR t.super_team_id = @superteamid::text);

-- ==================== Project SuperTeam Leaderboard ====================
Expand Down Expand Up @@ -599,6 +603,7 @@ team_scores AS (
LEFT JOIN score_journal sj ON sj.user_id = u.id AND sj.event_id = @eventid::text
WHERE
t.project_id = ep.project_id
AND t.leaderboard_excluded = false
GROUP BY t.id, t.name
),
ranked_scores AS (
Expand Down Expand Up @@ -632,6 +637,7 @@ WITH ranked_scores AS (
FROM leaderboard_event_teams let
INNER JOIN teams t ON let.team_id = t.id
WHERE let.event_id = @eventid::text
AND t.leaderboard_excluded = false
AND let.score >= COALESCE(@minscore::int, 1)
AND (@maxscore::int IS NULL OR let.score <= @maxscore::int)
),
Expand All @@ -658,6 +664,7 @@ WITH ranked_scores AS (
FROM leaderboard_event_teams let
INNER JOIN teams t ON let.team_id = t.id
WHERE let.event_id = @eventid::text
AND t.leaderboard_excluded = false
AND let.score >= COALESCE(@minscore::int, 1)
AND (@maxscore::int IS NULL OR let.score <= @maxscore::int)
)
Expand All @@ -672,7 +679,8 @@ WITH event_project AS (
SELECT COUNT(DISTINCT t.id)::bigint AS total
FROM teams t
CROSS JOIN event_project ep
WHERE t.project_id = ep.project_id;
WHERE t.project_id = ep.project_id
AND t.leaderboard_excluded = false;

-- ==================== Event SuperTeam Leaderboard ====================

Expand Down
38 changes: 28 additions & 10 deletions backend/internal/database/queries/teams.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- name: GetTeamsByIDs :many
SELECT id, project_id, name, description, join_code, super_team_id, created_at, updated_at
SELECT id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at
FROM teams
WHERE id = ANY(@ids::text[]);

-- name: GetTeamsFilteredCursor :many
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.created_at, t.updated_at
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.leaderboard_excluded, t.created_at, t.updated_at
FROM teams t
LEFT JOIN (
SELECT team_id, COUNT(*) as member_count
Expand Down Expand Up @@ -42,26 +42,26 @@ WHERE
AND (@maxmembers::int <= 0 OR COALESCE(tm.member_count, 0) <= @maxmembers::int);

-- name: GetTeamsByUserIDs :many
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.created_at, t.updated_at, tm.user_id
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.leaderboard_excluded, t.created_at, t.updated_at, tm.user_id
FROM teams t
INNER JOIN team_members tm ON t.id = tm.team_id
WHERE tm.user_id = ANY(@userids::text[])
ORDER BY t.name ASC;

-- name: GetTeamsBySuperTeamIDs :many
SELECT id, project_id, name, description, join_code, super_team_id, created_at, updated_at
SELECT id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at
FROM teams
WHERE super_team_id = ANY(@superteamids::text[])
ORDER BY name ASC;

-- name: GetTeamsByProjectIDs :many
SELECT id, project_id, name, description, join_code, super_team_id, created_at, updated_at
SELECT id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at
FROM teams
WHERE project_id = ANY(@project_ids::text[])
ORDER BY project_id, created_at DESC;

-- name: GetUserTeamByProjectID :one
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.created_at, t.updated_at
SELECT t.id, t.project_id, t.name, t.description, t.join_code, t.super_team_id, t.leaderboard_excluded, t.created_at, t.updated_at
FROM teams t
INNER JOIN team_members tm ON t.id = tm.team_id
WHERE tm.user_id = @userid::text
Expand All @@ -71,7 +71,7 @@ LIMIT 1;
-- name: CreateTeam :one
INSERT INTO teams (id, project_id, name, description, join_code)
VALUES (@id::text, @projectid::text, @name::text, @description::text, @joincode::text)
RETURNING id, project_id, name, description, join_code, super_team_id, created_at, updated_at;
RETURNING id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at;

-- name: UpdateTeam :one
UPDATE teams
Expand All @@ -80,22 +80,22 @@ SET
description = COALESCE(@description::text, description),
updated_at = now()
WHERE id = @id::text
RETURNING id, project_id, name, description, join_code, super_team_id, created_at, updated_at;
RETURNING id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at;

-- name: DeleteTeam :exec
DELETE FROM teams
WHERE id = @id::text;

-- name: GetTeamByJoinCode :one
SELECT id, project_id, name, description, join_code, super_team_id, created_at, updated_at
SELECT id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at
FROM teams
WHERE join_code = @joincode::text;

-- name: RegenerateJoinCode :one
UPDATE teams
SET join_code = @joincode::text, updated_at = now()
WHERE id = @id::text
RETURNING id, project_id, name, description, join_code, super_team_id, created_at, updated_at;
RETURNING id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at;

-- name: AddTeamMember :exec
INSERT INTO team_members (team_id, user_id)
Expand Down Expand Up @@ -221,3 +221,21 @@ SELECT DISTINCT tm.user_id
FROM team_members tm
JOIN teams t ON t.id = tm.team_id
WHERE t.super_team_id = ANY(@superteamids::text[]);

-- name: GetTeamAverageAge :one
SELECT COALESCE(
AVG(EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM u.birthdate)),
0
)::float AS average_age
FROM team_members tm
INNER JOIN users u ON tm.user_id = u.id
WHERE tm.team_id = @teamid::text
AND u.birthdate IS NOT NULL;

-- name: UpdateTeamLeaderboardExcluded :one
UPDATE teams
SET
leaderboard_excluded = @leaderboardexcluded::bool,
updated_at = now()
WHERE id = @id::text
RETURNING id, project_id, name, description, join_code, super_team_id, leaderboard_excluded, created_at, updated_at;
8 changes: 8 additions & 0 deletions backend/internal/database/sqlc/leaderboards.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions backend/internal/database/sqlc/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading