Verified Commit 500d6b40 authored by Leonidas Spyropoulos's avatar Leonidas Spyropoulos
Browse files

feat: add co-maintainers to RPC



Signed-off-by: Leonidas Spyropoulos's avatarLeonidas Spyropoulos <artafinde@archlinux.org>
parent bcd808dd
Pipeline #39776 passed with stages
in 2 minutes and 58 seconds
......@@ -284,6 +284,22 @@ class RPC:
)
.distinct()
.order_by("Name"),
# Co-Maintainer
db.query(models.PackageComaintainer)
.join(models.User, models.User.ID == models.PackageComaintainer.UsersID)
.join(
models.Package,
models.Package.PackageBaseID
== models.PackageComaintainer.PackageBaseID,
)
.with_entities(
models.Package.ID,
literal("CoMaintainers").label("Type"),
models.User.Username.label("Name"),
literal(str()).label("Cond"),
)
.distinct() # A package could have the same co-maintainer multiple times
.order_by("Name"),
]
# Union all subqueries together.
......
......@@ -272,6 +272,33 @@ def relations(user: User, packages: list[Package]) -> list[PackageRelation]:
yield output
@pytest.fixture
def comaintainer(
user2: User, user3: User, packages: list[Package]
) -> list[PackageComaintainer]:
output = []
with db.begin():
comaintainer = db.create(
PackageComaintainer,
User=user2,
PackageBase=packages[0].PackageBase,
Priority=1,
)
output.append(comaintainer)
comaintainer = db.create(
PackageComaintainer,
User=user3,
PackageBase=packages[0].PackageBase,
Priority=1,
)
output.append(comaintainer)
# Finally, yield the packages.
yield output
@pytest.fixture(autouse=True)
def setup(db_test):
# Create some extra package relationships.
......@@ -321,6 +348,7 @@ def test_rpc_singular_info(
packages: list[Package],
depends: list[PackageDependency],
relations: list[PackageRelation],
comaintainer: list[PackageComaintainer],
):
# Define expected response.
pkg = packages[0]
......@@ -343,6 +371,7 @@ def test_rpc_singular_info(
"MakeDepends": ["chungus-makedepends"],
"CheckDepends": ["chungus-checkdepends"],
"Conflicts": ["chungus-conflicts"],
"CoMaintainers": ["user2", "user3"],
"Provides": ["chungus-provides<=200"],
"Replaces": ["chungus-replaces<=200"],
"License": [pkg.package_licenses.first().License.Name],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment