new stats

This commit is contained in:
Michele Artini 2024-02-28 14:34:09 +01:00
parent 04dd31139b
commit 5ddbef3a5b
3 changed files with 57 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
@ -45,6 +46,7 @@ import eu.dnetlib.dhp.common.aggregation.AggregatorReport;
public class BaseAnalyzerJob {
private static final String BASE_DUMP = "BASE_DUMP";
private static final Logger log = LoggerFactory.getLogger(BaseAnalyzerJob.class);
public static void main(final String[] args) throws Exception {
@ -143,7 +145,10 @@ public class BaseAnalyzerJob {
.map(row -> {
final OpenDoarRepoStatus repo = new OpenDoarRepoStatus();
repo.setId(row.getString(0));
repo.getAggregations().put("BASE_DUMP", row.getLong(1));
repo.getAggregations().put(BASE_DUMP, row.getLong(1));
repo.setFromBase(true);
repo.setBaseMAX(true);
repo.setHighCompliance(false);
return repo;
}, Encoders.bean(OpenDoarRepoStatus.class));
@ -169,6 +174,23 @@ public class BaseAnalyzerJob {
r.setJurisdiction(ObjectUtils.firstNonNull(r1.getJurisdiction(), r2.getJurisdiction()));
r.getAggregations().putAll(r1.getAggregations());
r.getAggregations().putAll(r2.getAggregations());
r.setFromBase(r1.isFromBase() || r2.isFromBase());
r.setHighCompliance(r1.isHighCompliance() || r2.isHighCompliance());
if (r.getAggregations().containsKey(BASE_DUMP)) {
final long baseSize = r.getAggregations().get(BASE_DUMP);
final long otherSize = r
.getAggregations()
.entrySet()
.stream()
.filter(e -> !BASE_DUMP.equals(e.getKey()))
.mapToLong(Entry::getValue)
.max()
.orElse(0);
r.setBaseMAX(baseSize > otherSize);
} else {
r.setBaseMAX(false);
}
return r;
}
@ -195,6 +217,10 @@ public class BaseAnalyzerJob {
final String api = StringUtils.substringBefore(s, "@@@");
final long count = NumberUtils.toLong(StringUtils.substringAfter(s, "@@@"), 0);
repo.getAggregations().put(api, count);
repo.setFromBase(false);
repo.setBaseMAX(false);
// This should recognize the HIGH Compliances: openaire*X.Y*
repo.setHighCompliance(s.contains("compliance: openaire"));
}
repos.add(repo);
log.info("# FOUND OPENDOAR (DB): " + repo.getId());

View File

@ -13,6 +13,12 @@ public class OpenDoarRepoStatus implements Serializable {
private String jurisdiction;
private boolean fromBase = false;
private boolean highCompliance = false;
private boolean baseMAX = false;
private Map<String, Long> aggregations = new HashMap<>();
public String getId() {
@ -39,4 +45,27 @@ public class OpenDoarRepoStatus implements Serializable {
this.aggregations = aggregations;
}
public boolean isHighCompliance() {
return this.highCompliance;
}
public void setHighCompliance(final boolean highCompliance) {
this.highCompliance = highCompliance;
}
public boolean isFromBase() {
return this.fromBase;
}
public void setFromBase(final boolean fromBase) {
this.fromBase = fromBase;
}
public boolean isBaseMAX() {
return this.baseMAX;
}
public void setBaseMAX(final boolean baseMAX) {
this.baseMAX = baseMAX;
}
}

View File

@ -1,7 +1,7 @@
select
s.id as id,
s.jurisdiction as jurisdiction,
array_remove(array_agg(a.id || ' (' || coalesce(a.compatibility_override, a.compatibility, 'UNKNOWN') || ')@@@' || coalesce(a.last_collection_total, 0)), NULL) as aggregations
array_remove(array_agg(a.id || ' (compliance: ' || coalesce(a.compatibility_override, a.compatibility, 'UNKNOWN') || ')@@@' || coalesce(a.last_collection_total, 0)), NULL) as aggregations
from
dsm_services s
join dsm_api a on (s.id = a.service)