diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-10-30 13:22:48 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-10-30 13:34:44 +0000 |
commit | f1677fe73124a6066e5b22a6648a68868898b4a4 (patch) | |
tree | 4ef3767d1c6bd30545723c4f66ab7a4584f1f64b | |
parent | Don't refresh the package tree just after refreshing the package tree (diff) | |
download | gentoobrowse-api-f1677fe73124a6066e5b22a6648a68868898b4a4.tar.bz2 gentoobrowse-api-f1677fe73124a6066e5b22a6648a68868898b4a4.tar.xz gentoobrowse-api-f1677fe73124a6066e5b22a6648a68868898b4a4.zip |
Make PackageUse suitable for generic use
-rw-r--r-- | gentoobrowse-api/api/portage.ice | 2 | ||||
-rw-r--r-- | gentoobrowse-api/domain/extended-models.ice | 10 | ||||
-rw-r--r-- | gentoobrowse-api/domain/portage-models.ice | 10 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 4 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.h | 2 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getPackageUses.sql | 2 | ||||
-rw-r--r-- | 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<SearchResultPackage> SearchResultPackages; [ "slicer:element:bug" ] @@ -54,8 +46,6 @@ module Gentoo { sequence<PackageDependencyPackage> PackageDependencyPackages; [ "slicer:element:mask" ] sequence<PackageMask> PackageMasks; - [ "slicer:element:use" ] - sequence<PackageUse> 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<Category> Categories; [ "slicer:element:package" ] @@ -132,6 +140,8 @@ module Gentoo { sequence<Mask> Masks; [ "slicer:element:repo" ] sequence<Repository> Repositories; + [ "slicer:element:use" ] + sequence<Use> 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<Gentoo::PackageMasks>(sql::portage::getPackageMasks, 30, id); } -Gentoo::PackageUses +Gentoo::Uses Portage::getPackageUses(Ice::Int id, const Ice::Current &) { - return fetchCache<Gentoo::PackageUses>(sql::portage::getPackageUses, 30, id); + return fetchCache<Gentoo::Uses>(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 ) |