Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix for the date formatting issue #93

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ def format_match(self, hit: dict, collection: str, expanded: bool = False):
res["text_extraction"] = src.get("text_extraction")
return res

def format_day_counts(self, bucket: list):
return {item["key_as_string"][:10]: item["doc_count"] for item in bucket}

def format_counts(self, bucket: list):
return {item["key"]: item["doc_count"] for item in bucket}
def format_counts(self, bucket: list, day_counts=False):
if day_counts:
return {item["key_as_string"][:10]: item["doc_count"] for item in bucket}
else:
return {item["key"]: item["doc_count"] for item in bucket}

def aggregator_query(
self, collection: str, q: str, *aggs: QueryBuilder.Aggregators, **options
Expand All @@ -278,8 +278,9 @@ def aggregator_query(
# Add the results of each aggregator to the return value
for agg in aggs:
agg_name = list(agg.value.keys())[0]
return_dict.update(
{agg_name: self.format_counts(res["aggregations"][agg_name]["buckets"])}
return_dict[agg_name] = self.format_counts(
res["aggregations"][agg_name]["buckets"],
day_counts=(agg_name == "dailycounts"),
)

# Only return the total and matches if explicitly requested
Expand Down