Commit c65b5043 authored by Matija Obreza's avatar Matija Obreza

Improved query performance #lastUpdatedStatistics()

parent bb161207
......@@ -141,7 +141,7 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Modifying
public void updateCrop(Accession accession, Crop crop);
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute, count(a) from Accession a group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc, a.institute.code")
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute.id, count(a) from Accession a group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc, count(*), a.institute.id")
public List<Object[]> lastUpdatedStatistics();
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), count(a) from Accession a where a.institute = ?1 group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate) order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc")
......
......@@ -1835,7 +1835,11 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
@Cacheable(value = "statistics", unless = "#result == null", key = "'stats.' + #root.methodName")
public List<Object[]> getLastUpdatedStatistics() {
return accessionRepository.lastUpdatedStatistics();
List<Object[]> res = accessionRepository.lastUpdatedStatistics();
for (Object[] row : res) {
row[3] = instituteRepository.findOne((Long) row[3]);
}
return res;
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment