diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-11-04 15:27:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-11-04 15:27:46 +0000 |
commit | fd1044175e3f21fcca66ef5cc641694f48ad48be (patch) | |
tree | a0c44050229d2417eaf78be68580536732329770 | |
parent | Add support for getting a user's tracked packages (diff) | |
download | gentoobrowse-api-0.6.tar.bz2 gentoobrowse-api-0.6.tar.xz gentoobrowse-api-0.6.zip |
Add support for getting packaged details tracked by a usergentoobrowse-api-0.6
-rw-r--r-- | gentoobrowse-api/api/portage.ice | 1 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 7 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.h | 1 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql | 5 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 8 |
5 files changed, 22 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index 26c7987..d73c108 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -29,6 +29,7 @@ module Gentoo { idempotent PackageDependencyPackages getPackagesDepending(int id); idempotent PackageMasks getPackageMasks(int id); idempotent Uses getPackageUses(int id); + idempotent Packages getUserTrackedPackages(int userid); idempotent Use getUse(string flag) throws Slicer::NoRowsReturned; idempotent Uses getGlobalUses(); diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index bba0091..d3ab69e 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -16,6 +16,7 @@ #include <sql/portage/getPackageChangeLog.sql.h> #include <sql/portage/getPackagesWithRecentAdditions.sql.h> #include <sql/portage/getTopTrackedPackages.sql.h> +#include <sql/portage/getUserTrackedPackages.sql.h> #include <sql/portage/getRecentAdditions.sql.h> #include <sql/portage/getPackageDependencies.sql.h> #include <sql/portage/getPackageRuntimeDependencies.sql.h> @@ -160,6 +161,12 @@ Portage::getTopTrackedPackages(Ice::Int n, const Ice::Current &) return fetchCache<Gentoo::Packages>(sql::portage::getTopTrackedPackages, 30, n); } +Gentoo::Packages +Portage::getUserTrackedPackages(Ice::Int userid, const Ice::Current &) +{ + return fetchCache<Gentoo::Packages>(sql::portage::getUserTrackedPackages, 30, userid); +} + Gentoo::Categories Portage::getCategoriesWithRecentAdditions(Ice::Int syncs, const Ice::Current &) { diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h index 2600799..9b49e76 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -36,6 +36,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab Gentoo::PackageDependencyPackages getPackagesDepending(Ice::Int id, const Ice::Current &) override; Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override; Gentoo::Uses getPackageUses(Ice::Int id, const Ice::Current &) override; + Gentoo::Packages getUserTrackedPackages(Ice::Int userid, const Ice::Current &) override; Gentoo::UsePtr getUse(const std::string &, const Ice::Current &) override; Gentoo::Uses getGlobalUses(const Ice::Current &) override; diff --git a/gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql b/gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql new file mode 100644 index 0000000..02e61d0 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql @@ -0,0 +1,5 @@ +SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd +FROM gentoobrowse.packages p, gentoobrowse.user_packages up +WHERE p.packageid = up.packageid +AND up.userid = ? +ORDER BY p.packageid diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 7052d90..afb41e4 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -265,6 +265,14 @@ BOOST_AUTO_TEST_CASE( getPackageDependencies ) BOOST_REQUIRE_EQUAL(629007, d.back()->ebuildids.back()); } +BOOST_AUTO_TEST_CASE( getUserTrackedPackages ) +{ + auto ps = p->getUserTrackedPackages(1); + BOOST_REQUIRE_EQUAL(3, ps.size()); + BOOST_REQUIRE_EQUAL(49517, ps.front()->packageid); + BOOST_REQUIRE_EQUAL(55943, ps.back()->packageid); +} + BOOST_AUTO_TEST_CASE( getPackageRuntimeDependencies ) { auto d = p->getPackageRuntimeDependencies(54144); |