diff --git a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java index 006767cf3c2..2e68e076ad5 100644 --- a/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java +++ b/orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EventStatsDaoImpl.java @@ -25,8 +25,7 @@ public void createEventStats() { "INSERT INTO event_stats (event_type, client_id, count, date, date_created, last_modified) " + "SELECT event_type, client_id, COUNT(id), CAST(e.date_created as date), now(), now() " + "FROM event as e " + - "WHERE event_type != 'Public-Page' " + - "AND CAST(e.date_created as date) = CAST(now() - (CAST('1' AS INTERVAL DAY) * 1) as date) " + + "WHERE CAST(e.date_created as date) = CAST(now() - (CAST('1' AS INTERVAL DAY) * 1) as date) " + "GROUP BY event_type, client_id, CAST(e.date_created as date) " + "ORDER BY CAST(e.date_created as date) DESC;"; Query insertQuery = entityManager.createNativeQuery(query); diff --git a/orcid-persistence/src/main/resources/db-master.xml b/orcid-persistence/src/main/resources/db-master.xml index aee82d1bdc4..b168e83cc29 100644 --- a/orcid-persistence/src/main/resources/db-master.xml +++ b/orcid-persistence/src/main/resources/db-master.xml @@ -382,4 +382,5 @@ + diff --git a/orcid-persistence/src/main/resources/db/updates/dw_event_stats.xml b/orcid-persistence/src/main/resources/db/updates/dw_event_stats.xml new file mode 100644 index 00000000000..ff98617794b --- /dev/null +++ b/orcid-persistence/src/main/resources/db/updates/dw_event_stats.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + SELECT event_type, client_id, count, DATE_TRUNC('day', date), DATE_TRUNC('day', date) as last_modified + FROM event_stats + ORDER BY DATE_TRUNC('day', date_created) DESC; + + + + + + SELECT 1 FROM pg_roles WHERE rolname='dw_user' + + GRANT SELECT ON TABLE dw_event_stats to dw_user; + + + diff --git a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java index badd5330c9a..73c9edaf601 100644 --- a/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java +++ b/orcid-persistence/src/test/java/org/orcid/persistence/dao/EventStatsDaoTest.java @@ -1,6 +1,5 @@ package org.orcid.persistence.dao; -import org.apache.commons.lang3.reflect.FieldUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.orcid.persistence.jpa.entities.EventEntity; @@ -38,6 +37,7 @@ public void createEventStats() { assertNotNull(eventStatsEntityList); assertEquals(1, eventStatsEntityList.size()); + assertEquals(20, java.util.Optional.ofNullable(eventStatsEntityList.get(0).getCount())); } private void createEvents() { diff --git a/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml b/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml index 17214d3b0a7..2efe116212c 100644 --- a/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml +++ b/orcid-scheduler-web/src/main/resources/orcid-scheduler-context.xml @@ -42,7 +42,7 @@ - + diff --git a/orcid-test/src/main/resources/data/EventEntityData.xml b/orcid-test/src/main/resources/data/EventEntityData.xml index 9ac989cc1f1..83aa14b811b 100644 --- a/orcid-test/src/main/resources/data/EventEntityData.xml +++ b/orcid-test/src/main/resources/data/EventEntityData.xml @@ -13,7 +13,7 @@ />