Skip to content

Commit

Permalink
feat(invitation): provide flattened invitations
Browse files Browse the repository at this point in the history
A view is created that provides invitation data together with corresponding even and contact data.
  • Loading branch information
sthelemann committed Dec 11, 2024
1 parent c55cd8f commit 4ff342c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
46 changes: 46 additions & 0 deletions schema/schema.definition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,52 @@ COMMENT ON COLUMN maevsi.invitation.feedback IS 'The invitation''s general feedb
COMMENT ON COLUMN maevsi.invitation.feedback_paper IS 'The invitation''s paper feedback status.';


--
-- Name: invitation_flat; Type: VIEW; Schema: maevsi; Owner: postgres
--

CREATE VIEW maevsi.invitation_flat AS
SELECT i.id,
i.contact_id,
i.event_id,
i.feedback,
i.feedback_paper,
c.account_id AS contact_account_id,
c.address,
c.author_account_id AS contact_author_account_id,
c.email_address,
c.email_address_hash,
c.first_name,
c.last_name,
c.phone_number,
c.url AS contact_url,
e.author_account_id AS event_author_account_id,
e.description,
e.start,
e."end",
e.invitee_count_maximum,
e.is_archived,
e.is_in_person,
e.is_remote,
e.location,
e.name,
e.slug,
e.url AS event_url,
e.visibility
FROM ((maevsi.invitation i
JOIN maevsi.contact c ON ((i.contact_id = c.id)))
JOIN maevsi.event e ON ((i.event_id = e.id)));


ALTER VIEW maevsi.invitation_flat OWNER TO postgres;

--
-- Name: VIEW invitation_flat; Type: COMMENT; Schema: maevsi; Owner: postgres
--

COMMENT ON VIEW maevsi.invitation_flat IS 'View returning flattened invitations.';


--
-- Name: legal_term; Type: TABLE; Schema: maevsi; Owner: postgres
--
Expand Down
21 changes: 21 additions & 0 deletions src/deploy/view_invitation_flat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Deploy maevsi:view_invitation_flat to pg
-- requires: schema_public
-- requires: table_invitation
-- requires: table_contact

BEGIN;
CREATE VIEW maevsi.invitation_flat AS
SELECT i.*,
c.account_id as contact_account_id, c.address, c.author_account_id as contact_author_account_id, c.email_address, c.email_address_hash,
c.first_name, c.last_name, c.phone_number, c.url as contact_url,
e.author_account_id as event_author_account_id, e.description, e.start, e.end,
e.invitee_count_maximum, e.is_archived, e.is_in_person, e.is_remote,
e.location, e.name, e.slug, e.url as event_url, e.visibility
FROM maevsi.invitation i
JOIN maevsi.contact c ON i.contact_id = c.id
JOIN maevsi.event e ON i.event_id = e.id
;

COMMENT ON VIEW maevsi.invitation_flat IS 'View returning flattened invitations.';

END;
7 changes: 7 additions & 0 deletions src/revert/view_invitation_flat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert maevsi:view_invitation_flat from pg

BEGIN;

DROP VIEW maevsi.invitation_flat;

COMMIT;
1 change: 1 addition & 0 deletions src/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ table_report [schema_public table_account_public table_event table_upload] 1970-
table_report_policy [schema_public table_report role_account] 1970-01-01T00:00:00Z Marlon <[email protected]> # Access policies for reports.
table_legal_term [schema_public role_account role_anonymous] 1970-01-01T00:00:00Z Jonas Thelemann <e-mail+maevsi/[email protected]> # Legal terms like privacy policies or terms of service.
table_legal_term_acceptance [schema_public table_account_public table_legal_term role_account] 1970-01-01T00:00:00Z Jonas Thelemann <e-mail+maevsi/[email protected]> # Tracks each user account's acceptance of legal terms and conditions.
view_invitation_flat [schema_public table_invitation table_contact role_account] 1970-01-01T00:00:00Z Sven Thelemann <[email protected]> # View returning flattened invitations
14 changes: 14 additions & 0 deletions src/verify/view_invitation_flat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Verify maevsi:view_invitation_flat on pg

BEGIN;

SELECT
id, contact_id, event_id, feedback, feedback_paper,
contact_account_id, address, contact_author_account_id, email_address, email_address_hash,
first_name, last_name, phone_number, contact_url,
event_author_account_id, description, "start", "end",
invitee_count_maximum, is_archived, is_in_person, is_remote,
location, name, slug, event_url, visibility
FROM maevsi.invitation_flat WHERE FALSE;

ROLLBACK;

0 comments on commit 4ff342c

Please sign in to comment.