From 01ebbdf9e88e3072fa7d633077b6dd6b2c47b535 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 17 Dec 2016 14:37:53 +0000 Subject: Add method for getting recent versions for user tracked packages --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + .../service/sql/portage/getUserTrackedRecentVersions.sql | 6 ++++++ gentoobrowse-api/unittests/testPortage.cpp | 8 ++++++++ 5 files changed, 23 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getUserTrackedRecentVersions.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index d73c108..1671c91 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -30,6 +30,7 @@ module Gentoo { idempotent PackageMasks getPackageMasks(int id); idempotent Uses getPackageUses(int id); idempotent Packages getUserTrackedPackages(int userid); + idempotent Ebuilds getUserTrackedRecentVersions(int userid, int limit); 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 d3ab69e..ac83557 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -167,6 +168,12 @@ Portage::getUserTrackedPackages(Ice::Int userid, const Ice::Current &) return fetchCache(sql::portage::getUserTrackedPackages, 30, userid); } +Gentoo::Ebuilds +Portage::getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice::Current &) +{ + return fetchCache(sql::portage::getUserTrackedRecentVersions, 30, userid, limit); +} + 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 9b49e76..b27f2a0 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -37,6 +37,7 @@ 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::Packages getUserTrackedPackages(Ice::Int userid, const Ice::Current &) override; + Gentoo::Ebuilds getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, 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/getUserTrackedRecentVersions.sql b/gentoobrowse-api/service/sql/portage/getUserTrackedRecentVersions.sql new file mode 100644 index 0000000..1f59500 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getUserTrackedRecentVersions.sql @@ -0,0 +1,6 @@ +SELECT e.ebuildid, e.packageid, e.repoid, e.version, e.slot, e.firstseen, e.moddate, e.license +FROM gentoobrowse.user_packages up, gentoobrowse.ebuilds e +WHERE up.userid = ? +AND up.packageid = e.packageid +ORDER BY e.firstseen +LIMIT ? diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index ae6224d..fdfd1f9 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -273,6 +273,14 @@ BOOST_AUTO_TEST_CASE( getUserTrackedPackages ) BOOST_REQUIRE_EQUAL(55943, ps.back()->packageid); } +BOOST_AUTO_TEST_CASE( getUserTrackedRecentVersions ) +{ + auto ps = p->getUserTrackedRecentVersions(1, 4); + BOOST_REQUIRE_EQUAL(4, ps.size()); + BOOST_REQUIRE_EQUAL(55943, ps.front()->packageid); + BOOST_REQUIRE_EQUAL(54144, ps.back()->packageid); +} + BOOST_AUTO_TEST_CASE( getPackageRuntimeDependencies ) { auto d = p->getPackageRuntimeDependencies(54144); -- cgit v1.2.3