Skip to content

Commit

Permalink
Updating data catalog request to utilize the unique doc counts
Browse files Browse the repository at this point in the history
Updating data catalog request to utilize the unique doc counts
  • Loading branch information
rushirajnenuji committed Dec 2, 2021
1 parent 1be8611 commit 305f459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/d1_metrics/d1_metrics/metricselasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def get_aggregations(self,
search_body["aggs"]["pid_list"]["composite"]["after"] = {}
search_body["aggs"]["pid_list"]["composite"]["after"] = after_record
self._L.debug("Request: %s", str(search_body))
resp = self._es.search(body=search_body, request_timeout=None)
resp = self._es.search(body=search_body, request_timeout=self._config["request_timeout"])
return(resp)


Expand Down
11 changes: 9 additions & 2 deletions src/d1_metrics_service/d1_metrics_service/metricsreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ def getSummaryMetricsPerCatalog(self, requestPIDArray, a_type):
}
}
}
},
"aggs": {
"unique_doc_count": {
"cardinality": {
"field": "eventId"
}
}
}
}

Expand Down Expand Up @@ -609,12 +616,12 @@ def formatDataPerCatalog(self, data, catalogPIDs):

for i in catalogPIDs:
if i in dataCounts:
results["downloads"].append(dataCounts[i]["buckets"]["pid.key"]["doc_count"])
results["downloads"].append(dataCounts[i]["buckets"]["pid.key"]["unique_doc_count"]["value"])
else:
results["downloads"].append(0)

if i in metadataCounts:
results["views"].append(metadataCounts[i]["buckets"]["pid.key"]["doc_count"])
results["views"].append(metadataCounts[i]["buckets"]["pid.key"]["unique_doc_count"]["value"])
else:
results["views"].append(0)

Expand Down

0 comments on commit 305f459

Please sign in to comment.