diff --git a/app/lists/mirror_mapping.py b/app/lists/mirror_mapping.py index 659326d..8414611 100644 --- a/app/lists/mirror_mapping.py +++ b/app/lists/mirror_mapping.py @@ -1,10 +1,12 @@ # pylint: disable=too-few-public-methods import builtins +import datetime from typing import Dict, List, Union from flask import current_app from pydantic import BaseModel, Field +from pydantic.typing import Optional from tldextract import extract from app.models.base import Group, Pool @@ -15,6 +17,8 @@ class MMMirror(BaseModel): origin_domain: str = Field(description="The full origin domain name") origin_domain_normalized: str = Field(description="The origin_domain with \"www.\" removed, if present") origin_domain_root: str = Field(description="The registered domain name of the origin, excluding subdomains") + valid_from: str = Field(description="The date on which the mirror was added to the system") + valid_to: Optional[str] = Field(description="The date on which the mirror was decommissioned") class MirrorMapping(BaseModel): @@ -39,7 +43,9 @@ def mirror_mapping(pool: Pool) -> Dict[str, Union[str, Dict[str, str]]]: d.url.lstrip("https://"): MMMirror( origin_domain=d.origin.domain_name, origin_domain_normalized=d.origin.domain_name.replace("www.", ""), - origin_domain_root=extract(d.origin.domain_name).registered_domain + origin_domain_root=extract(d.origin.domain_name).registered_domain, + valid_from=d.origin.added.isoformat(), + valid_to=d.origin.destroyed.isoformat() if d.origin.destroyed is not None else None ) for d in Proxy.query.all() if d.url is not None }, s3_buckets=[