Skip to content

Commit

Permalink
Merge pull request #6924 from ORCID/8906-panoply-its-unable-to-retrie…
Browse files Browse the repository at this point in the history
…ve-information-from-dwevent-and-dweventpublicpage

fix: Add missing `last_modified` in events view so panoply can run su…
  • Loading branch information
amontenegro authored Nov 1, 2023
2 parents 14c3164 + 763a8da commit 58c5a0a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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>

0 comments on commit 58c5a0a

Please sign in to comment.