-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MET-6078 Add latest data to historical result
- Loading branch information
1 parent
3e23ed0
commit 056cb7f
Showing
4 changed files
with
51 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 2 additions & 33 deletions
35
...rc/main/java/eu/europeana/statistics/dashboard/worker/execution/HistoricalDataRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,26 @@ | ||
package eu.europeana.statistics.dashboard.worker.execution; | ||
|
||
import eu.europeana.statistics.dashboard.common.internal.model.Historical; | ||
import eu.europeana.statistics.dashboard.common.internal.MongoStatisticsField; | ||
import eu.europeana.statistics.dashboard.service.persistence.MongoSDDao; | ||
import eu.europeana.statistics.dashboard.service.persistence.StatisticsData; | ||
import eu.europeana.statistics.dashboard.service.persistence.StatisticsQuery; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
|
||
public class HistoricalDataRunner{ | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzerRunner.class); | ||
|
||
public static void runHistoricalScript(MongoSDDao mongoSDDao){ | ||
List<String> countries = mongoSDDao.getAllCountryValuesTargetCollection(); | ||
|
||
for(String country : countries) { | ||
writeHistoricalData(country,mongoSDDao); | ||
writeHistoricalData(country, mongoSDDao); | ||
} | ||
} | ||
|
||
|
||
private static void writeHistoricalData(String country, MongoSDDao mongoSDDao){ | ||
LOGGER.info("Starting historical data process for {}", country); | ||
StatisticsQuery query3D = mongoSDDao.createStatisticsQuery(); | ||
query3D.withValueFilter(MongoStatisticsField.COUNTRY, List.of(country)); | ||
query3D.withValueFilter(MongoStatisticsField.TYPE, List.of("3D")); | ||
query3D.withValueFilter(MongoStatisticsField.CONTENT_TIER, List.of("1", "2", "3", "4")); //Exclude content tier 0 | ||
StatisticsData result3dQuery = query3D.queryForStatistics(); | ||
|
||
StatisticsQuery queryHighQuality = mongoSDDao.createStatisticsQuery(); | ||
queryHighQuality.withValueFilter(MongoStatisticsField.COUNTRY, List.of(country)); | ||
queryHighQuality.withValueFilter(MongoStatisticsField.CONTENT_TIER, List.of("2", "3", "4")); | ||
queryHighQuality.withValueFilter(MongoStatisticsField.METADATA_TIER, List.of("A", "B", "C")); | ||
StatisticsData resultHighQualityQuery = queryHighQuality.queryForStatistics(); | ||
|
||
StatisticsQuery queryTotalRecords = mongoSDDao.createStatisticsQuery(); | ||
queryTotalRecords.withValueFilter(MongoStatisticsField.COUNTRY, List.of(country)); | ||
queryTotalRecords.withValueFilter(MongoStatisticsField.CONTENT_TIER, List.of("1", "2", "3", "4")); //Exclude content tier 0 | ||
StatisticsData resultTotalRecords = queryTotalRecords.queryForStatistics(); | ||
|
||
Historical result = new Historical(country, result3dQuery.getRecordCount(), | ||
resultHighQualityQuery.getRecordCount(), resultTotalRecords.getRecordCount(), LocalDateTime.now()); | ||
|
||
Historical result = mongoSDDao.generateHistoricalSnapshot(country); | ||
mongoSDDao.saveHistoricalRecord(result); | ||
|
||
LOGGER.info("Finished historical data process for {}", country); | ||
|
||
} | ||
|
||
|
||
} |