Fix domain reports and sources API 500 errors
- Use begin_timestamp/end_timestamp (Unix ints) instead of begin_date/end_date (ISO strings) when building ReportEntry, fixing Pydantic int_parsing errors - Extract policy string from dict (policy["p"]) when the stored value is a dict, fixing Pydantic string_type validation error - Rename _days -> days in ReportStore.get_domain_sources() so the endpoint's `days=days` keyword call no longer raises TypeError Agent-Logs-Url: https://github.com/christianlouis/dmarq/sessions/15ac3521-e81f-42fa-81a2-f6804a423e1d Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -371,15 +371,18 @@ async def get_domain_reports(
|
|||||||
# Generate report entries
|
# Generate report entries
|
||||||
report_entries = []
|
report_entries = []
|
||||||
for report in reports:
|
for report in reports:
|
||||||
|
policy_val = report.get("policy", "none")
|
||||||
|
if isinstance(policy_val, dict):
|
||||||
|
policy_val = policy_val.get("p", "none")
|
||||||
report_entries.append(
|
report_entries.append(
|
||||||
ReportEntry(
|
ReportEntry(
|
||||||
id=report.get("report_id", "unknown"),
|
id=report.get("report_id", "unknown"),
|
||||||
org_name=report.get("org_name", "Unknown Organization"),
|
org_name=report.get("org_name", "Unknown Organization"),
|
||||||
begin_date=report.get("begin_date", 0),
|
begin_date=report.get("begin_timestamp", 0),
|
||||||
end_date=report.get("end_date", 0),
|
end_date=report.get("end_timestamp", 0),
|
||||||
total_emails=report.get("total_count", 0),
|
total_emails=report.get("total_count", 0),
|
||||||
pass_rate=report.get("pass_rate", 0.0),
|
pass_rate=report.get("pass_rate", 0.0),
|
||||||
policy=report.get("policy", "none"),
|
policy=policy_val,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class ReportStore:
|
|||||||
return sorted_reports[:limit]
|
return sorted_reports[:limit]
|
||||||
return sorted_reports
|
return sorted_reports
|
||||||
|
|
||||||
def get_domain_sources(self, domain: str, _days: int = 30) -> List[Dict[str, Any]]:
|
def get_domain_sources(self, domain: str, days: int = 30) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Get sending sources for a domain
|
Get sending sources for a domain
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user