mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: add co-maintainers to RPC
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
bcd808ddc1
commit
500d6b403b
2 changed files with 45 additions and 0 deletions
|
@ -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],
|
||||
|
|
Loading…
Add table
Reference in a new issue