Commit b10395a0 authored by Matija Obreza's avatar Matija Obreza

Make institute statistics pageable

parent a79de6bc
......@@ -38,11 +38,11 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query("select count(a) from Accession a where a.institute = ?1")
long countByInstitute(FaoInstitute institute);
@Query("select t.genus, count(a) as x from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by x desc")
List<Object[]> statisticsGenusInInstitute(FaoInstitute institute);
@Query("select t.genus, count(a) from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by count(a) desc")
Page<Object[]> statisticsGenusInInstitute(FaoInstitute institute, Pageable pageable);
@Query("select taxonomy, count(a) as x from Accession a where a.institute = ?1 group by a.taxonomy order by x desc")
List<Object[]> statisticsTaxonomyInInstitute(FaoInstitute institute);
@Query("select taxonomy, count(a) from Accession a where a.institute = ?1 group by a.taxonomy order by count(a) desc")
Page<Object[]> statisticsTaxonomyInInstitute(FaoInstitute institute, Pageable pageable);
@Query("select count(a) from Accession a where a.origin = ?1")
long countByOrigin(String isoCode3);
......
......@@ -82,9 +82,9 @@ public interface GenesysService {
Page<Accession> listAccessions(Collection<Long> accessionIds, Pageable pageable);
List<Object[]> statisticsGenusByInstitute(FaoInstitute faoInstitute);
Page<Object[]> statisticsGenusByInstitute(FaoInstitute faoInstitute, Pageable pageable);
List<Object[]> statisticsTaxonomyByInstitute(FaoInstitute faoInstitute);
Page<Object[]> statisticsTaxonomyByInstitute(FaoInstitute faoInstitute, Pageable pageable);
Page<Accession> listAccessionsByInstituteAndTaxonomy(FaoInstitute institute, Taxonomy taxonomy, Pageable pageable);
......
......@@ -215,13 +215,13 @@ public class GenesysServiceImpl implements GenesysService, TraitService {
}
@Override
public List<Object[]> statisticsGenusByInstitute(FaoInstitute institute) {
return accessionRepository.statisticsGenusInInstitute(institute);
public Page<Object[]> statisticsGenusByInstitute(FaoInstitute institute, Pageable pageable) {
return accessionRepository.statisticsGenusInInstitute(institute, pageable);
}
@Override
public List<Object[]> statisticsTaxonomyByInstitute(FaoInstitute institute) {
return accessionRepository.statisticsTaxonomyInInstitute(institute);
public Page<Object[]> statisticsTaxonomyByInstitute(FaoInstitute institute, Pageable pageable) {
return accessionRepository.statisticsTaxonomyInInstitute(institute, pageable);
}
@Override
......
......@@ -77,10 +77,8 @@ public class WiewsController extends BaseController {
model.addAttribute("countByInstitute", genesysService.countByInstitute(faoInstitute));
// FIXME some institutes have *a lot* of different taxa
// TODO needs pagination
model.addAttribute("statisticsGenus", genesysService.statisticsGenusByInstitute(faoInstitute).subList(0, 30));
model.addAttribute("statisticsTaxonomy", genesysService.statisticsTaxonomyByInstitute(faoInstitute).subList(0, 30));
model.addAttribute("statisticsGenus", genesysService.statisticsGenusByInstitute(faoInstitute, new PageRequest(0, 30)));
model.addAttribute("statisticsTaxonomy", genesysService.statisticsTaxonomyByInstitute(faoInstitute, new PageRequest(0, 30)));
return "/wiews/details";
}
......
......@@ -57,18 +57,18 @@
<div class="clearfix" style="margin-top: 2em;">
<div class="pull-left" style="margin-right: 3em;">
<h4>Top 30 by Genus</h4>
<h4>Top ${statisticsGenus.numberOfElements} by Genus</h4>
<ul class="funny-list statistics">
<c:forEach items="${statisticsGenus}" var="stat" varStatus="status">
<c:forEach items="${statisticsGenus.content}" var="stat" varStatus="status">
<li><span class="stats-number"><fmt:formatNumber value="${stat[1]}" /></span> <c:out value="${stat[0]}" /></li>
</c:forEach>
</ul>
</div>
<div class="pull-left" style="margin-right: 3em;">
<h4>Top 30 by Species</h4>
<h4>Top ${statisticsTaxonomy.numberOfElements} by Species</h4>
<ul class="funny-list statistics">
<c:forEach items="${statisticsTaxonomy}" var="stat" varStatus="status">
<c:forEach items="${statisticsTaxonomy.content}" var="stat" varStatus="status">
<li><span class="stats-number"><fmt:formatNumber value="${stat[1]}" /></span> <a href="<c:url value="/wiews/${faoInstitute.code.toLowerCase()}/t/${stat[0].genus}/${stat[0].species}" />"><c:out value="${stat[0].taxonName}" /></a></li>
</c:forEach>
</ul>
......
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