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

add build_date from artifact metadata #90

Merged
merged 1 commit into from
Jun 20, 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
24 changes: 22 additions & 2 deletions server/process_incoming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing_extensions import TypedDict

import contextlib
import datetime
import hashlib
import fnmatch
import functools
Expand Down Expand Up @@ -198,6 +199,7 @@ class Package(TypedDict):
version_key: str # 1.0.0~alpha.6~dev.5069.2020091300~nightly
architecture: str # x86_64
revision: str # 2020091300~nightly
build_date: str # 2023-12-14T21:30:16+00:00
installrefs: list[InstallRef]
installref: str

Expand Down Expand Up @@ -271,7 +273,13 @@ def remove_old(
channel: str | None = None,
) -> None:
logger.info("remove_old: %s %s %s %s", bucket, prefix, keep, channel)
index: dict[str, dict[semver.VersionInfo, list[str]]] = {}
index: dict[
str,
dict[
tuple[semver.Version, datetime.datetime],
list[str],
],
] = {}
prefix_str = str(prefix) + "/"
for obj in bucket.objects.filter(Prefix=prefix_str):
if is_metadata_object(obj.key):
Expand Down Expand Up @@ -305,7 +313,15 @@ def remove_old(
for p in ver_details["prerelease"]
),
)
index.setdefault(key, {}).setdefault(version, []).append(obj.key)
build_date_str = metadata.get("build_date")
if build_date_str:
build_date = datetime.datetime.fromisoformat(build_date_str)
else:
build_date = datetime.datetime.fromtimestamp(
0, tz=datetime.timezone.utc
)
ver_key = (version, build_date)
index.setdefault(key, {}).setdefault(ver_key, []).append(obj.key)

for _, versions in index.items():
sorted_versions = sorted(versions, reverse=True)
Expand Down Expand Up @@ -384,6 +400,10 @@ def append_artifact(
version_details=version_details,
version_key=version_key,
revision=metadata["revision"],
build_date=metadata.get(
"build_date",
"1970-01-01T00:00:00+00:00",
),
architecture=metadata["architecture"],
installref=installref["ref"],
installrefs=[installref],
Expand Down
Loading