diff options
-rw-r--r-- | gentoobrowse-api/api/portage.ice | 7 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 42 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.h | 7 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getGlobalUses.sql | 3 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getGroupUses.sql | 5 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUse.sql | 3 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUseGroups.sql | 3 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUsePackages.sql | 14 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUseUsage.sql | 13 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 84 |
10 files changed, 181 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index abcc854..c7d7da6 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -30,6 +30,13 @@ module Gentoo { idempotent PackageMasks getPackageMasks(int id); idempotent Uses getPackageUses(int id); + idempotent Use getUse(string flag) throws Slicer::NoRowsReturned; + idempotent Uses getGlobalUses(); + idempotent Uses getGroupUses(string group); + idempotent StringList getUseGroups(); + idempotent Uses getUseUsage(string flag); + idempotent Packages getUsePackages(string flag); + idempotent Bug getBug(int id) throws Slicer::NoRowsReturned; idempotent Bugs getPackageBugs(int packageId); idempotent SearchResultBugs getBugsSearch(string query); diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 32a2b4d..f39653c 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -22,6 +22,12 @@ #include <sql/portage/getPackagesDepending.sql.h> #include <sql/portage/getPackageMasks.sql.h> #include <sql/portage/getPackageUses.sql.h> +#include <sql/portage/getUse.sql.h> +#include <sql/portage/getGlobalUses.sql.h> +#include <sql/portage/getGroupUses.sql.h> +#include <sql/portage/getUseGroups.sql.h> +#include <sql/portage/getUseUsage.sql.h> +#include <sql/portage/getUsePackages.sql.h> #include <sql/portage/getSyncs.sql.h> #include <sql/portage/getBug.sql.h> #include <sql/portage/getPackageBugs.sql.h> @@ -189,6 +195,42 @@ Portage::getPackageUses(Ice::Int id, const Ice::Current &) return fetchCache<Gentoo::Uses>(sql::portage::getPackageUses, 30, id); } +Gentoo::UsePtr +Portage::getUse(const std::string & use, const Ice::Current &) +{ + return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use); +} + +Gentoo::Uses +Portage::getGlobalUses(const Ice::Current &) +{ + return fetchCache<Gentoo::Uses>(sql::portage::getGlobalUses, 30); +} + +Gentoo::Uses +Portage::getGroupUses(const std::string & group, const Ice::Current &) +{ + return fetchCache<Gentoo::Uses>(sql::portage::getGroupUses, 30, group); +} + +Gentoo::StringList +Portage::getUseGroups(const Ice::Current &) +{ + return fetchCache<Gentoo::StringList>(sql::portage::getUseGroups, 30); +} + +Gentoo::Uses +Portage::getUseUsage(const std::string & use, const Ice::Current &) +{ + return fetchCache<Gentoo::Uses>(sql::portage::getUseUsage, 30, use, use, use, use); +} + +Gentoo::Packages +Portage::getUsePackages(const std::string & use, const Ice::Current &) +{ + return fetchCache<Gentoo::Packages>(sql::portage::getUsePackages, 30, use, use); +} + Gentoo::BugPtr Portage::getBug(Ice::Int id, const Ice::Current &) { diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h index 423788c..5440b6b 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -37,6 +37,13 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override; Gentoo::Uses getPackageUses(Ice::Int id, const Ice::Current &) override; + Gentoo::UsePtr getUse(const std::string &, const Ice::Current &) override; + Gentoo::Uses getGlobalUses(const Ice::Current &) override; + Gentoo::Uses getGroupUses(const std::string &, const Ice::Current &) override; + Gentoo::StringList getUseGroups(const Ice::Current &) override; + Gentoo::Uses getUseUsage(const std::string &, const Ice::Current &) override; + Gentoo::Packages getUsePackages(const std::string &, const Ice::Current &) override; + Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override; Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override; Gentoo::SearchResultBugs getBugsSearch(const std::string & query, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/sql/portage/getGlobalUses.sql b/gentoobrowse-api/service/sql/portage/getGlobalUses.sql new file mode 100644 index 0000000..d361add --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getGlobalUses.sql @@ -0,0 +1,3 @@ +SELECT use, description +FROM gentoobrowse.use_global +ORDER BY use diff --git a/gentoobrowse-api/service/sql/portage/getGroupUses.sql b/gentoobrowse-api/service/sql/portage/getGroupUses.sql new file mode 100644 index 0000000..16029b8 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getGroupUses.sql @@ -0,0 +1,5 @@ +SELECT name "group", g.use, g.description +FROM gentoobrowse.use_group g, gentoobrowse.use_groups gs +WHERE gs.name = ? +AND g.usegroupid = gs.usegroupid +ORDER BY g.use diff --git a/gentoobrowse-api/service/sql/portage/getUse.sql b/gentoobrowse-api/service/sql/portage/getUse.sql new file mode 100644 index 0000000..ceaccf2 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUse.sql @@ -0,0 +1,3 @@ +SELECT use, description +FROM gentoobrowse.use_global +WHERE use = ? diff --git a/gentoobrowse-api/service/sql/portage/getUseGroups.sql b/gentoobrowse-api/service/sql/portage/getUseGroups.sql new file mode 100644 index 0000000..cc87d2b --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUseGroups.sql @@ -0,0 +1,3 @@ +SELECT name +FROM gentoobrowse.use_groups +ORDER BY name diff --git a/gentoobrowse-api/service/sql/portage/getUsePackages.sql b/gentoobrowse-api/service/sql/portage/getUsePackages.sql new file mode 100644 index 0000000..80912dd --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUsePackages.sql @@ -0,0 +1,14 @@ +SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd +FROM gentoobrowse.packages p + LEFT OUTER JOIN gentoobrowse.use_local ul + ON p.packageid = ul.packageid + AND ul.use = ? + LEFT OUTER JOIN gentoobrowse.ebuilds e + ON p.packageid = e.packageid + LEFT OUTER JOIN gentoobrowse.ebuild_uses eu + ON e.ebuildid = eu.ebuildid + AND eu.use = ? +WHERE eu.use IS NOT NULL +OR ul.use IS NOT NULL +GROUP BY p.packageid +ORDER BY p.name diff --git a/gentoobrowse-api/service/sql/portage/getUseUsage.sql b/gentoobrowse-api/service/sql/portage/getUseUsage.sql new file mode 100644 index 0000000..afd3081 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUseUsage.sql @@ -0,0 +1,13 @@ +SELECT LTRIM(use, '+') use, description, packageid, SUBSTRING(use, 1, 1) = '+' isdefault, null "group" +FROM gentoobrowse.use_local ul +WHERE ul.use = ? +UNION ALL +SELECT use, description, null, null, null +FROM gentoobrowse.use_global ug +WHERE ug.use = ? +UNION ALL +SELECT use, description, null, null, name +FROM gentoobrowse.use_groups ugs, gentoobrowse.use_group ug +WHERE ugs.usegroupid = ug.usegroupid +AND ugs.name like SPLIT_PART(?, '_', 1) || '%' +AND ugs.name || '_' || ug.use = ?
\ No newline at end of file diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 6e5577e..ee8f96b 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -314,6 +314,90 @@ BOOST_AUTO_TEST_CASE( getPackageUses ) BOOST_REQUIRE(!us[2]->packageid); } +BOOST_AUTO_TEST_CASE( getUse ) +{ + auto u = p->getUse("X"); + BOOST_REQUIRE_EQUAL("X", u->use); + BOOST_REQUIRE_EQUAL("Add support for X11", u->description); + BOOST_REQUIRE(!u->packageid); + BOOST_REQUIRE(!u->isdefault); + BOOST_REQUIRE(!u->group); +} + +BOOST_AUTO_TEST_CASE( getUseMissing ) +{ + BOOST_REQUIRE_THROW(p->getUse("nothing"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( getGlobalUses ) +{ + auto us = p->getGlobalUses(); + BOOST_REQUIRE_EQUAL(393, us.size()); + BOOST_REQUIRE_EQUAL("3dfx", us.front()->use); + BOOST_REQUIRE_EQUAL("Enable support for Voodoo chipsets, also called as 3DFX and TDFX", us.front()->description); + BOOST_REQUIRE(!us.front()->packageid); + BOOST_REQUIRE(!us.front()->isdefault); + BOOST_REQUIRE(!us.front()->group); + BOOST_REQUIRE_EQUAL("zsh-completion", us.back()->use); + BOOST_REQUIRE_EQUAL("Enable zsh completion support", us.back()->description); + BOOST_REQUIRE(!us.back()->packageid); + BOOST_REQUIRE(!us.back()->isdefault); + BOOST_REQUIRE(!us.back()->group); +} + +BOOST_AUTO_TEST_CASE( getGroupUses ) +{ + auto gs = p->getGroupUses("abi_x86"); + BOOST_REQUIRE_EQUAL(3, gs.size()); + BOOST_REQUIRE(gs.front()->group); + BOOST_REQUIRE_EQUAL("abi_x86", *gs.front()->group); + BOOST_REQUIRE_EQUAL("32", gs.front()->use); + BOOST_REQUIRE_EQUAL("32-bit (x86) libraries", gs.front()->description); + BOOST_REQUIRE(!gs.front()->isdefault); + BOOST_REQUIRE(!gs.front()->packageid); + BOOST_REQUIRE(gs.back()->group); + BOOST_REQUIRE_EQUAL("abi_x86", *gs.back()->group); + BOOST_REQUIRE_EQUAL("x32", gs.back()->use); + BOOST_REQUIRE_EQUAL("x32 ABI libraries", gs.back()->description); + BOOST_REQUIRE(!gs.back()->isdefault); + BOOST_REQUIRE(!gs.back()->packageid); +} + +BOOST_AUTO_TEST_CASE( getUseGroups ) +{ + auto gs = p->getUseGroups(); + BOOST_REQUIRE_EQUAL(49, gs.size()); + BOOST_REQUIRE_EQUAL("abi_mips", gs.front()); + BOOST_REQUIRE_EQUAL("xtables_addons", gs.back()); +} + +BOOST_AUTO_TEST_CASE( getUseUsage ) +{ + auto uu = p->getUseUsage("usb"); + BOOST_REQUIRE_EQUAL(3, uu.size()); + BOOST_REQUIRE(uu.front()->packageid); + BOOST_REQUIRE(!uu.back()->isdefault); + BOOST_REQUIRE(!uu.back()->group); + BOOST_REQUIRE_EQUAL(47193, *uu.front()->packageid); + BOOST_REQUIRE_EQUAL("usb", uu.front()->use); + BOOST_REQUIRE_EQUAL("Build direct CCID access for scdaemon; requires dev-libs/libusb.", uu.front()->description); + BOOST_REQUIRE(!uu.back()->packageid); + BOOST_REQUIRE(!uu.back()->isdefault); + BOOST_REQUIRE(!uu.back()->group); + BOOST_REQUIRE_EQUAL("usb", uu.back()->use); + BOOST_REQUIRE_EQUAL("Add USB support to applications that have optional USB support (e.g. cups)", uu.back()->description); +} + +BOOST_AUTO_TEST_CASE( getUsePackages ) +{ + auto ps = p->getUsePackages("usb"); + BOOST_REQUIRE_EQUAL(2, ps.size()); + BOOST_REQUIRE_EQUAL(55373, ps.front()->packageid); + BOOST_REQUIRE_EQUAL("ekeyd", ps.front()->name); + BOOST_REQUIRE_EQUAL(47193, ps.back()->packageid); + BOOST_REQUIRE_EQUAL("gnupg", ps.back()->name); +} + BOOST_AUTO_TEST_CASE( getBugMissing ) { BOOST_REQUIRE_THROW(p->getBug(10), Slicer::NoRowsReturned); |