From ccd33422089b0ad7dbad2d7b70427670962837bc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 4 Nov 2016 15:27:46 +0000 Subject: Add support for getting packaged details tracked by a user --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql | 5 +++++ gentoobrowse-api/unittests/testPortage.cpp | 8 ++++++++ 5 files changed, 22 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getUserTrackedPackages.sql 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 #include #include +#include #include #include #include @@ -160,6 +161,12 @@ Portage::getTopTrackedPackages(Ice::Int n, const Ice::Current &) return fetchCache(sql::portage::getTopTrackedPackages, 30, n); } +Gentoo::Packages +Portage::getUserTrackedPackages(Ice::Int userid, const Ice::Current &) +{ + return fetchCache(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); -- cgit v1.2.3