backend/source/repositories/sql/calendar_overview.sql

16 lines
600 B
MySQL
Raw Normal View History

2024-09-21 10:56:00 +02:00
SELECT
x.id AS id,
JSON_AGG(x.name) AS name,
JSON_AGG(x.hue) AS hue,
JSON_AGG(x.access_public) AS access_public,
JSON_AGG(x.access_level_default) AS access_level_default,
JSON_AGG(y1.level) AS access_level_attributed_group,
JSON_AGG(y2.level) AS access_level_attributed_user
2024-09-21 10:56:00 +02:00
FROM
calendars AS x
2025-10-23 11:34:00 +02:00
LEFT OUTER JOIN calendar_access_attributed_group AS y1 ON ((x.id = y1.calendar_id) AND (y1.group_id IN (SELECT group_id FROM user_groups WHERE (user_id = $user_id))))
LEFT OUTER JOIN calendar_access_attributed_user AS y2 ON ((x.id = y2.calendar_id) AND (y2.user_id = $user_id))
GROUP BY
x.id
2024-09-21 10:56:00 +02:00
;