From f1677fe73124a6066e5b22a6648a68868898b4a4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 30 Oct 2016 13:22:48 +0000 Subject: Make PackageUse suitable for generic use --- gentoobrowse-api/api/portage.ice | 2 +- gentoobrowse-api/domain/extended-models.ice | 10 ---------- gentoobrowse-api/domain/portage-models.ice | 10 ++++++++++ gentoobrowse-api/service/portageimpl.cpp | 4 ++-- gentoobrowse-api/service/portageimpl.h | 2 +- gentoobrowse-api/service/sql/portage/getPackageUses.sql | 2 +- gentoobrowse-api/unittests/testPortage.cpp | 9 +++++---- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index fee89f4..abcc854 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -28,7 +28,7 @@ module Gentoo { idempotent PackageDependencyPackages getPackageRuntimeDependencies(int id); idempotent PackageDependencyPackages getPackagesDepending(int id); idempotent PackageMasks getPackageMasks(int id); - idempotent PackageUses getPackageUses(int id); + idempotent Uses getPackageUses(int id); idempotent Bug getBug(int id) throws Slicer::NoRowsReturned; idempotent Bugs getPackageBugs(int packageId); diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice index 1d37342..aee4af1 100644 --- a/gentoobrowse-api/domain/extended-models.ice +++ b/gentoobrowse-api/domain/extended-models.ice @@ -32,14 +32,6 @@ module Gentoo { IntList ebuildids; }; - class PackageUse { - string use; - bool islocal; - optional(0) string group; - string name; - string description; - }; - [ "slicer:element:package" ] sequence SearchResultPackages; [ "slicer:element:bug" ] @@ -54,8 +46,6 @@ module Gentoo { sequence PackageDependencyPackages; [ "slicer:element:mask" ] sequence PackageMasks; - [ "slicer:element:use" ] - sequence PackageUses; }; #endif diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice index 5b7ddff..71930b0 100644 --- a/gentoobrowse-api/domain/portage-models.ice +++ b/gentoobrowse-api/domain/portage-models.ice @@ -114,6 +114,14 @@ module Gentoo { string path; }; + class Use { + optional(0) string group; + optional(1) int packageid; + bool isdefault = false; + string use; + string description; + }; + [ "slicer:element:category" ] sequence Categories; [ "slicer:element:package" ] @@ -132,6 +140,8 @@ module Gentoo { sequence Masks; [ "slicer:element:repo" ] sequence Repositories; + [ "slicer:element:use" ] + sequence Uses; }; #endif diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 198a893..32a2b4d 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -183,10 +183,10 @@ Portage::getPackageMasks(Ice::Int id, const Ice::Current &) return fetchCache(sql::portage::getPackageMasks, 30, id); } -Gentoo::PackageUses +Gentoo::Uses Portage::getPackageUses(Ice::Int id, const Ice::Current &) { - return fetchCache(sql::portage::getPackageUses, 30, id); + return fetchCache(sql::portage::getPackageUses, 30, id); } Gentoo::BugPtr diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h index ea6ad5f..423788c 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -35,7 +35,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab Gentoo::PackageDependencyPackages getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &) override; Gentoo::PackageDependencyPackages getPackagesDepending(Ice::Int id, const Ice::Current &) override; Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override; - Gentoo::PackageUses getPackageUses(Ice::Int id, const Ice::Current &) override; + Gentoo::Uses getPackageUses(Ice::Int id, const Ice::Current &) override; Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override; Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/sql/portage/getPackageUses.sql b/gentoobrowse-api/service/sql/portage/getPackageUses.sql index 50d6c0a..0d14a64 100644 --- a/gentoobrowse-api/service/sql/portage/getPackageUses.sql +++ b/gentoobrowse-api/service/sql/portage/getPackageUses.sql @@ -1,4 +1,4 @@ -SELECT eu.use, ul.use IS NOT NULL islocal, ugg.name AS group, LTRIM(COALESCE(ugg.use, eu.use), '+') AS name, +SELECT SUBSTRING(COALESCE(ugg.use, eu.use), 1, 1) = '+' isdefault, ul.packageid, ugg.name AS group, LTRIM(COALESCE(ugg.use, eu.use), '+') AS use, COALESCE(ul.description, ugg.description, ug.description) description FROM gentoobrowse.ebuilds e JOIN gentoobrowse.ebuild_uses eu diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index ab0f466..6e5577e 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -302,15 +302,16 @@ BOOST_AUTO_TEST_CASE( getPackageUses ) { auto us = p->getPackageUses(46436); BOOST_REQUIRE_EQUAL(19, us.size()); - BOOST_REQUIRE_EQUAL("+keyutils", us.front()->use); - BOOST_REQUIRE_EQUAL("keyutils", us.front()->name); - BOOST_REQUIRE_EQUAL(true, us.front()->islocal); + BOOST_REQUIRE_EQUAL("keyutils", us.front()->use); + BOOST_REQUIRE(us.front()->isdefault); + BOOST_REQUIRE(us.front()->packageid); + BOOST_REQUIRE_EQUAL(46436, us.front()->packageid); BOOST_REQUIRE(!us[0]->group); BOOST_REQUIRE(us[9]->group); BOOST_REQUIRE_EQUAL("abi_mips", *us[9]->group); BOOST_REQUIRE_EQUAL("Enable for the keyring ccache using keyutils.", us[0]->description); BOOST_REQUIRE_EQUAL("selinux", us[6]->use); - BOOST_REQUIRE_EQUAL(false, us[2]->islocal); + BOOST_REQUIRE(!us[2]->packageid); } BOOST_AUTO_TEST_CASE( getBugMissing ) -- cgit v1.2.3