Skip to content

Commit

Permalink
Merge branch 'feature/relational-db' into add-identical-motion-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister committed Apr 19, 2024
2 parents 7e253f4 + 936d185 commit fae58a6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ jobs:
if: always()
run: make pyupgrade

# - name: Validate models.yml
# if: always()
# run: make validate-models
- name: Validate models.yml
if: always()
run: make validate-models
18 changes: 9 additions & 9 deletions dev/sql/schema_relational.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BEGIN
END;
$$ LANGUAGE plpgsql;

-- MODELS_YML_CHECKSUM = '2007f6054e0baa149f98b80cbe9ed670'
-- MODELS_YML_CHECKSUM = '82f9031bf779d97f165fdce1ceb5cf71'
-- Type definitions

-- Table definitions
Expand Down Expand Up @@ -1357,7 +1357,7 @@ CREATE OR REPLACE VIEW meeting AS SELECT *,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_agenda_item_list_in_meeting_id = m.id) as default_projector_agenda_item_list_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_topic_in_meeting_id = m.id) as default_projector_topic_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_list_of_speakers_in_meeting_id = m.id) as default_projector_list_of_speakers_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_current_los_in_meeting_id = m.id) as default_projector_current_list_of_speakers_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_current_los_in_meeting_id = m.id) as default_projector_current_los_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_motion_in_meeting_id = m.id) as default_projector_motion_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_amendment_in_meeting_id = m.id) as default_projector_amendment_ids,
(select array_agg(p.id) from projector_t p where p.used_as_default_projector_for_motion_block_in_meeting_id = m.id) as default_projector_motion_block_ids,
Expand Down Expand Up @@ -1814,12 +1814,12 @@ CREATE CONSTRAINT TRIGGER tr_ud_meeting_default_projector_list_of_speakers_ids A
FOR EACH ROW EXECUTE FUNCTION check_not_null_for_relation_lists('meeting', 'default_projector_list_of_speakers_ids', 'used_as_default_projector_for_list_of_speakers_in_meeting_id');


-- definition trigger not null for meeting.default_projector_current_list_of_speakers_ids against projector_t.used_as_default_projector_for_current_los_in_meeting_id
CREATE CONSTRAINT TRIGGER tr_i_meeting_default_projector_current_list_of_speakers_ids AFTER INSERT ON projector_t INITIALLY DEFERRED
FOR EACH ROW EXECUTE FUNCTION check_not_null_for_relation_lists('meeting', 'default_projector_current_list_of_speakers_ids', 'used_as_default_projector_for_current_los_in_meeting_id');
-- definition trigger not null for meeting.default_projector_current_los_ids against projector_t.used_as_default_projector_for_current_los_in_meeting_id
CREATE CONSTRAINT TRIGGER tr_i_meeting_default_projector_current_los_ids AFTER INSERT ON projector_t INITIALLY DEFERRED
FOR EACH ROW EXECUTE FUNCTION check_not_null_for_relation_lists('meeting', 'default_projector_current_los_ids', 'used_as_default_projector_for_current_los_in_meeting_id');

CREATE CONSTRAINT TRIGGER tr_ud_meeting_default_projector_current_list_of_speakers_ids AFTER UPDATE OF used_as_default_projector_for_current_los_in_meeting_id OR DELETE ON projector_t
FOR EACH ROW EXECUTE FUNCTION check_not_null_for_relation_lists('meeting', 'default_projector_current_list_of_speakers_ids', 'used_as_default_projector_for_current_los_in_meeting_id');
CREATE CONSTRAINT TRIGGER tr_ud_meeting_default_projector_current_los_ids AFTER UPDATE OF used_as_default_projector_for_current_los_in_meeting_id OR DELETE ON projector_t
FOR EACH ROW EXECUTE FUNCTION check_not_null_for_relation_lists('meeting', 'default_projector_current_los_ids', 'used_as_default_projector_for_current_los_in_meeting_id');


-- definition trigger not null for meeting.default_projector_motion_ids against projector_t.used_as_default_projector_for_motion_in_meeting_id
Expand Down Expand Up @@ -2046,7 +2046,7 @@ SQL nt:1GrR => meeting/projection_ids:-> projection/content_object_id
SQL ntR:1r => meeting/default_projector_agenda_item_list_ids:-> projector/used_as_default_projector_for_agenda_item_list_in_meeting_id
SQL ntR:1r => meeting/default_projector_topic_ids:-> projector/used_as_default_projector_for_topic_in_meeting_id
SQL ntR:1r => meeting/default_projector_list_of_speakers_ids:-> projector/used_as_default_projector_for_list_of_speakers_in_meeting_id
SQL ntR:1r => meeting/default_projector_current_list_of_speakers_ids:-> projector/used_as_default_projector_for_current_los_in_meeting_id
SQL ntR:1r => meeting/default_projector_current_los_ids:-> projector/used_as_default_projector_for_current_los_in_meeting_id
SQL ntR:1r => meeting/default_projector_motion_ids:-> projector/used_as_default_projector_for_motion_in_meeting_id
SQL ntR:1r => meeting/default_projector_amendment_ids:-> projector/used_as_default_projector_for_amendment_in_meeting_id
SQL ntR:1r => meeting/default_projector_motion_block_ids:-> projector/used_as_default_projector_for_motion_block_in_meeting_id
Expand Down Expand Up @@ -2327,4 +2327,4 @@ There are 3 errors/warnings
projection/content: type:JSON is marked as a calculated field and not generated in schema
*/

/* Missing attribute handling for constant, on_delete, sqlTODO, sql, equal_fields, unique, deferred */
/* Missing attribute handling for constant, on_delete, equal_fields, unique, deferred */
2 changes: 2 additions & 0 deletions dev/src/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"required",
"read_only",
"constant",
"unique",
)


Expand Down Expand Up @@ -201,6 +202,7 @@ def check_field(
valid_attributes.append("equal_fields")
if nested and type in ("relation", "relation-list"):
valid_attributes.append("enum")
valid_attributes.extend(("reference", "deferred", "sql"))

for attr in field.keys():
if attr not in valid_attributes:
Expand Down
47 changes: 24 additions & 23 deletions models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# r = reference, will result in a FIELD
# to = to, collection with field get's an automatic sql in a view, if not together with `reference`
# R = required
# The first tuple symbols the relation from-to, the 2nd FIELD or SQL and primary or not, only valis for lists
# The first tuple symbols the relation from-to, the 2nd FIELD or SQL and primary or not, only valid for lists
# The original of the following list is used in source code as `decision_list`
# ("1Gr", ""): (FieldSqlErrorType.FIELD, False),
# ("1GrR", ""): (FieldSqlErrorType.FIELD, False),
Expand Down Expand Up @@ -362,15 +362,15 @@ user:
restriction_mode: E
read_only: true
description: "Calculated field: Returns committee_ids, where the user is manager or member in a meeting"
sqlTODO: >-
(select array_agg(committee_id) from
select m.committee_id as committee_id from group_to_user gtu
join groupT g on g.id = gtu.group_id
join meetingT m on m.id = g.meeting_id
where gtu.user_id = u.id
union
select ctu.committee_id as committee_id from committee_manager_to_user ctu where ctu.user_id = u.id
) as committee_ids
# sql: >- # TODO
# (select array_agg(committee_id) from
# select m.committee_id as committee_id from group_to_user gtu
# join groupT g on g.id = gtu.group_id
# join meetingT m on m.id = g.meeting_id
# where gtu.user_id = u.id
# union
# select ctu.committee_id as committee_id from committee_manager_to_user ctu where ctu.user_id = u.id
# ) as committee_ids

# committee specific permissions
committee_management_ids:
Expand Down Expand Up @@ -414,7 +414,7 @@ user:
type: number[]
description: Calculated. All ids from meetings calculated via meeting_user and group_ids as integers.
read_only: true
sql: todo
# sql: todo
restriction_mode: E
organization_id:
type: relation
Expand Down Expand Up @@ -747,15 +747,15 @@ committee:
restriction_mode: A
read_only: true
description: "Calculated field: All users which are in a group of a meeting, belonging to the committee or beeing manager of the committee"
sqlTODO: >-
(select array_agg(user_id) from
select gtu.user_id as user_id from meetingT m
join groupT g on g.meeting_id = m.id
join group_to_user gtu on gtu.group_id = g.id
where m.committee_id = c.id
union
select ctu.user_id as user_id from committee_manager_to_user ctu where ctu.committee_id = c.id
) as user_ids
# sql: >- # TODO
# (select array_agg(user_id) from
# select gtu.user_id as user_id from meetingT m
# join groupT g on g.meeting_id = m.id
# join group_to_user gtu on gtu.group_id = g.id
# where m.committee_id = c.id
# union
# select ctu.user_id as user_id from committee_manager_to_user ctu where ctu.committee_id = c.id
# ) as user_ids
manager_ids:
type: relation-list
to: user/committee_management_ids
Expand Down Expand Up @@ -1767,12 +1767,12 @@ meeting:
restriction_mode: B
logo_pdf_footer_l_id:
type: relation
to: mediafile/used_as_logo_pdf_header_l_in_meeting_id
to: mediafile/used_as_logo_pdf_footer_l_in_meeting_id
reference: mediafile
restriction_mode: B
logo_pdf_footer_r_id:
type: relation
to: mediafile/used_as_logo_pdf_header_l_in_meeting_id
to: mediafile/used_as_logo_pdf_footer_r_in_meeting_id
reference: mediafile
restriction_mode: B
logo_pdf_ballot_paper_id:
Expand Down Expand Up @@ -1844,6 +1844,7 @@ meeting:
type: number[]
description: Calculated. All user ids from all users assigned to groups of this meeting.
read_only: true
# sql: todo
restriction_mode: B
reference_projector_id:
type: relation
Expand Down Expand Up @@ -1881,7 +1882,7 @@ meeting:
to: projector/used_as_default_projector_for_list_of_speakers_in_meeting_id
restriction_mode: B
required: true
default_projector_current_list_of_speakers_ids:
default_projector_current_los_ids:
type: relation-list
to: projector/used_as_default_projector_for_current_los_in_meeting_id
restriction_mode: B
Expand Down

0 comments on commit fae58a6

Please sign in to comment.