feat: add field "Submitter" to metadata-archives

This commit is contained in:
Mario Oenning 2022-10-28 16:55:16 +00:00 committed by Leonidas Spyropoulos
parent 48e5dc6763
commit 333051ab1f
2 changed files with 12 additions and 1 deletions

View file

@ -163,6 +163,7 @@ def as_dict(package: Package) -> dict[str, Any]:
"Popularity": float(package.Popularity), "Popularity": float(package.Popularity),
"OutOfDate": package.OutOfDate, "OutOfDate": package.OutOfDate,
"Maintainer": package.Maintainer, "Maintainer": package.Maintainer,
"Submitter": package.Submitter,
"FirstSubmitted": package.FirstSubmitted, "FirstSubmitted": package.FirstSubmitted,
"LastModified": package.LastModified, "LastModified": package.LastModified,
} }
@ -190,10 +191,13 @@ def _main():
logger.warning(f"{sys.argv[0]} is deprecated and will be soon be removed") logger.warning(f"{sys.argv[0]} is deprecated and will be soon be removed")
logger.info("Started re-creating archives, wait a while...") logger.info("Started re-creating archives, wait a while...")
Submitter = orm.aliased(User)
query = ( query = (
db.query(Package) db.query(Package)
.join(PackageBase, PackageBase.ID == Package.PackageBaseID) .join(PackageBase, PackageBase.ID == Package.PackageBaseID)
.join(User, PackageBase.MaintainerUID == User.ID, isouter=True) .join(User, PackageBase.MaintainerUID == User.ID, isouter=True)
.join(Submitter, PackageBase.SubmitterUID == Submitter.ID, isouter=True)
.filter(PackageBase.PackagerUID.isnot(None)) .filter(PackageBase.PackagerUID.isnot(None))
.with_entities( .with_entities(
Package.ID, Package.ID,
@ -207,6 +211,7 @@ def _main():
PackageBase.Popularity, PackageBase.Popularity,
PackageBase.OutOfDateTS.label("OutOfDate"), PackageBase.OutOfDateTS.label("OutOfDate"),
User.Username.label("Maintainer"), User.Username.label("Maintainer"),
Submitter.Username.label("Submitter"),
PackageBase.SubmittedTS.label("FirstSubmitted"), PackageBase.SubmittedTS.label("FirstSubmitted"),
PackageBase.ModifiedTS.label("LastModified"), PackageBase.ModifiedTS.label("LastModified"),
) )

View file

@ -30,6 +30,7 @@ META_KEYS = [
"Popularity", "Popularity",
"OutOfDate", "OutOfDate",
"Maintainer", "Maintainer",
"Submitter",
"FirstSubmitted", "FirstSubmitted",
"LastModified", "LastModified",
"URLPath", "URLPath",
@ -61,7 +62,12 @@ def packages(user: User) -> list[Package]:
lic = db.create(License, Name="GPL") lic = db.create(License, Name="GPL")
for i in range(5): for i in range(5):
# Create the package. # Create the package.
pkgbase = db.create(PackageBase, Name=f"pkgbase_{i}", Packager=user) pkgbase = db.create(
PackageBase,
Name=f"pkgbase_{i}",
Packager=user,
Submitter=user,
)
pkg = db.create(Package, PackageBase=pkgbase, Name=f"pkg_{i}") pkg = db.create(Package, PackageBase=pkgbase, Name=f"pkg_{i}")
# Create some related records. # Create some related records.