Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing last_modified in events view so panoply can run su… #6924

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions orcid-persistence/src/main/resources/db-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,5 @@
<include file="/db/updates/create_event_table.xml" />
<include file="/db/updates/dw_event.xml" />
<include file="/db/updates/create_event_indexes.xml" />
<include file="/db/updates/dw_alter_event.xml" />
</databaseChangeLog>
43 changes: 43 additions & 0 deletions orcid-persistence/src/main/resources/db/updates/dw_alter_event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<changeSet id="ALTER-DW-EVENT-VIEW-GROUP-BY-DAY-CLIENT_ID-AND-EVENT_TYPE" author="Daniel Palafox" dbms="postgresql">
<dropView viewName="dw_event"/>

<createView viewName="dw_event">
SELECT event_type, client_id, COUNT(id), DATE_TRUNC('day', date_created), DATE_TRUNC('day', date_created) as last_modified
FROM event
WHERE event_type != 'Public-Page'
GROUP BY event_type, client_id, DATE_TRUNC('day', date_created)
ORDER BY DATE_TRUNC('day', date_created) DESC;
</createView>
</changeSet>

<changeSet id="GRANT-READ-TO-DW_USER-TO-DW_EVENT-VIEW" author="Daniel Palafox" dbms="postgresql">
<preConditions>
<sqlCheck expectedResult="1">SELECT 1 FROM pg_roles WHERE rolname='dw_user'</sqlCheck>
</preConditions>
<sql>GRANT SELECT ON TABLE dw_event to dw_user;</sql>
</changeSet>

<changeSet id="ALTER-DW-EVENT-VIEW-GROUP-BY-PUBLIC-PAGE" author="Daniel Palafox" dbms="postgresql">
<dropView viewName="dw_event_public_page"/>

<createView viewName="dw_event_public_page">
SELECT event_type, public_page, COUNT(id), DATE_TRUNC('day', date_created), DATE_TRUNC('day', date_created) as last_modified
FROM event
WHERE event_type = 'Public-Page'
GROUP BY event_type, public_page, DATE_TRUNC('day', date_created)
ORDER BY DATE_TRUNC('day', date_created) DESC;
</createView>
</changeSet>

<changeSet id="GRANT-READ-TO-DW-EVENT-VIEW-GROUP-BY-PUBLIC-PAGE" author="Daniel Palafox" dbms="postgresql">
<preConditions>
<sqlCheck expectedResult="1">SELECT 1 FROM pg_roles WHERE rolname='dw_user'</sqlCheck>
</preConditions>
<sql>GRANT SELECT ON TABLE dw_event_public_page to dw_user;</sql>
</changeSet>

</databaseChangeLog>