From 654e8273bd74efa42936321086b03ddafe7d53af Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 19 Jan 2017 19:52:09 +0000 Subject: Add missing method to get package URLs --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + gentoobrowse-api/service/sql/portage/getPackageUrls.sql | 4 ++++ gentoobrowse-api/unittests/testPortage.cpp | 7 +++++++ 5 files changed, 20 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getPackageUrls.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index 1671c91..fe159ad 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -31,6 +31,7 @@ module Gentoo { idempotent Uses getPackageUses(int id); idempotent Packages getUserTrackedPackages(int userid); idempotent Ebuilds getUserTrackedRecentVersions(int userid, int limit); + idempotent StringList getPackageUrls(int id); 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 ac83557..bb8a215 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -40,6 +40,7 @@ #include #include #include +#include namespace Gentoo { namespace Service { @@ -174,6 +175,12 @@ Portage::getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice return fetchCache(sql::portage::getUserTrackedRecentVersions, 30, userid, limit); } +Gentoo::StringList +Portage::getPackageUrls(Ice::Int id, const Ice::Current &) +{ + return fetchCache(sql::portage::getPackageUrls, 30, id); +} + 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 b27f2a0..be8742a 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -38,6 +38,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab 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::StringList getPackageUrls(Ice::Int id, 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/getPackageUrls.sql b/gentoobrowse-api/service/sql/portage/getPackageUrls.sql new file mode 100644 index 0000000..109b0d9 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getPackageUrls.sql @@ -0,0 +1,4 @@ +SELECT url +FROM gentoobrowse.package_urls +WHERE packageid = ? +ORDER BY url diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 588ad8c..b235c4e 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -283,6 +283,13 @@ BOOST_AUTO_TEST_CASE( getUserTrackedRecentVersions ) BOOST_REQUIRE_EQUAL("2015-10-17T15:00:13.238126", ps.back()->firstseen); } +BOOST_AUTO_TEST_CASE( getPackageUrls ) +{ + auto urls = p->getPackageUrls(54144); + BOOST_REQUIRE_EQUAL(1, urls.size()); + BOOST_REQUIRE_EQUAL("http://www.git-scm.com/", urls.front()); +} + BOOST_AUTO_TEST_CASE( getPackageRuntimeDependencies ) { auto d = p->getPackageRuntimeDependencies(54144); -- cgit v1.2.3