Skip to content

Commit

Permalink
Do not store the stats from here, do it from the dw script.
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Jan 2, 2024
1 parent 76ad9ae commit dccbd8e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 135 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@
</preConditions>
<sql>GRANT SELECT ON event_stats to orcidro;</sql>
</changeSet>

<changeSet id="GRANT-PERMISSIONS-TO-DW-USER-ON-EVENT_STATS" author="Angel Montenegro" dbms="postgresql">
<preConditions>
<sqlCheck expectedResult="1">SELECT 1 FROM pg_roles WHERE rolname='dw_user'</sqlCheck>
</preConditions>
<sql>GRANT SELECT,INSERT,UPDATE,DELETE ON event_stats TO dw_user;</sql>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,12 @@

<bean id="eventDao" class="org.orcid.persistence.dao.impl.EventDaoImpl" />

<bean id="eventStatsDao" class="org.orcid.persistence.dao.impl.EventStatsDaoImpl" />

<bean id="emailDomainDao" class="org.orcid.persistence.dao.impl.EmailDomainDaoImpl" />

<bean id="emailDomainDaoReadOnly" class="org.orcid.persistence.dao.impl.EmailDomainDaoImpl">
<property name="entityManager" ref="entityManagerReadOnly" />
</bean>


<!-- Statistics -->
<bean id="statisticsDao" class="org.orcid.persistence.dao.impl.StatisticsDaoImpl">
<property name="entityManager" ref="entityManager" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

public interface EventStats {

void saveEventStats();

void deleteEvents();
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
package org.orcid.scheduler.web.event.impl;

import javax.annotation.Resource;

import org.orcid.core.togglz.Features;
import org.orcid.persistence.dao.EventDao;
import org.orcid.persistence.dao.EventStatsDao;
import org.orcid.scheduler.web.event.EventStats;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import java.time.LocalDate;

public class EventStatsImpl implements EventStats {

private static final Logger LOGGER = LoggerFactory.getLogger(EventStatsImpl.class);

@Resource(name = "eventDao")
private EventDao eventDao;

@Resource(name = "eventStatsDao")
private EventStatsDao eventStatsDao;

@Value("${org.orcid.scheduler.event.deleteEvents.numberOfDays:90}")
private int DELETE_EVENTS_OLDER_THAN_DAYS;

@Override
public void saveEventStats() {
LocalDate date = LocalDate.now().minusDays(1);
String currentDate = date.getDayOfMonth() + "/" + date.getMonth() + "/" + date.getYear();
LOGGER.debug("Storing aggregate data to event_stats table of the day" + currentDate);
eventStatsDao.createEventStats();
}

@Override
public void deleteEvents() {
if (Features.DELETE_EVENTS.isActive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
<task:scheduled ref="emailMessageSender" method="addWorksToRecordFirstReminder" cron="${org.orcid.scheduler.web.addWorksToRecord.firstReminder:0 10 * * * *}"/>
<task:scheduled ref="emailMessageSender" method="addWorksToRecordSecondReminder" cron="${org.orcid.scheduler.web.addWorksToRecord.secondReminder:0 20 * * * *}"/>
<task:scheduled ref="emailMessageSender" method="addWorksToRecordThirdReminder" cron="${org.orcid.scheduler.web.addWorksToRecord.thirdReminder:0 30 * * * *}"/>
<task:scheduled ref="eventStats" method="deleteEvents" cron="${org.orcid.scheduler.web.deleteEventsOlderDays:0 10 * * * *}"/>
<task:scheduled ref="eventStats" method="saveEventStats" cron="${org.orcid.scheduler.web.saveEventStats:0 10 * * * *}"/>
<task:scheduled ref="eventStats" method="deleteEvents" cron="${org.orcid.scheduler.web.deleteEventsOlderDays:0 15 0 * * *}"/>
</task:scheduled-tasks>

<task:scheduler id="scheduler" pool-size="${org.orcid.scheduler.tasks.pool_size:30}"/>
Expand Down

0 comments on commit dccbd8e

Please sign in to comment.