Aggregate coverage paper counts once per snapshot
Metadata integrity checks / metadata (push) Successful in 1m17s
Metadata integrity checks / metadata (push) Successful in 1m17s
This commit is contained in:
@@ -47,6 +47,16 @@ def report(db, registry, *, pg_service=None, pg_schema=None):
|
||||
database, schema = str(Path(db).resolve()), None
|
||||
latest = _status_counts(connection, latest=True)
|
||||
observations = _status_counts(connection, latest=False)
|
||||
# Aggregate the paper join once for the whole snapshot. Repeating it
|
||||
# for each registry target caused repeated scans on the production DB.
|
||||
edition_counts = {}
|
||||
for row in connection.execute('''SELECT s.edition_id,count(s.id) AS submissions,
|
||||
count(DISTINCT s.paper_id) AS papers,
|
||||
count(DISTINCT CASE WHEN p.abstract IS NULL OR p.abstract='' THEN s.paper_id END)
|
||||
AS papers_without_abstract_text
|
||||
FROM submissions s LEFT JOIN papers p ON p.id=s.paper_id GROUP BY s.edition_id'''):
|
||||
entry = dict(row)
|
||||
edition_counts[entry.pop('edition_id')] = entry
|
||||
source_counts = defaultdict(list)
|
||||
for row in connection.execute('''SELECT s.edition_id,so.name AS source,
|
||||
count(DISTINCT sr.id) AS source_records,
|
||||
@@ -63,14 +73,12 @@ def report(db, registry, *, pg_service=None, pg_schema=None):
|
||||
params = (acronym, acronym)
|
||||
editions = []
|
||||
for row in connection.execute('''SELECT e.id,v.id AS venue_id,v.acronym AS canonical_venue,
|
||||
e.year,e.track,count(s.id) AS submissions,count(DISTINCT s.paper_id) AS papers,
|
||||
count(DISTINCT CASE WHEN p.abstract IS NULL OR p.abstract='' THEN s.paper_id END)
|
||||
AS papers_without_abstract_text
|
||||
FROM editions e JOIN venues v ON v.id=e.venue_id
|
||||
LEFT JOIN submissions s ON s.edition_id=e.id LEFT JOIN papers p ON p.id=s.paper_id
|
||||
WHERE ''' + scope + ''' GROUP BY e.id,v.id,v.acronym,e.year,e.track
|
||||
e.year,e.track FROM editions e JOIN venues v ON v.id=e.venue_id
|
||||
WHERE ''' + scope + '''
|
||||
ORDER BY e.year,e.track,v.acronym''', params):
|
||||
edition = dict(row)
|
||||
edition.update(edition_counts.get(row['id'], {
|
||||
'submissions': 0, 'papers': 0, 'papers_without_abstract_text': 0}))
|
||||
covered_venue_ids.add(edition['venue_id'])
|
||||
edition['latest_observed_status_counts'] = {status: latest[row['id']].get(status, 0) for status in STATUSES}
|
||||
edition['decision_observation_counts'] = {status: observations[row['id']].get(status, 0) for status in STATUSES}
|
||||
|
||||
Reference in New Issue
Block a user