From cfb87501dce6c2408f298c4e3ac422f3e3affc49 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 11 Dec 2015 00:43:44 +0000 Subject: Get package versions --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + .../service/sql/portage/getPackageVersions.sql | 4 ++++ gentoobrowse-api/unittests/testPortage.cpp | 17 +++++++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getPackageVersions.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index 00f4730..2101a76 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -12,6 +12,7 @@ module Gentoo { idempotent optional(0) Package findPackage(string category, string package); idempotent Packages getPackagesInCategory(int id); idempotent SearchResultPackages getPackagesSearch(string query); + idempotent Ebuilds getPackageVersions(int id); idempotent Bug getBug(int id); idempotent Bugs getPackageBugs(int packageId); diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 9e495e2..f2c593a 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,12 @@ Portage::getPackagesSearch(const std::string & query, const Ice::Current &) return fetch(query, query); } +Gentoo::Ebuilds +Portage::getPackageVersions(Ice::Int id, const Ice::Current &) +{ + return fetch(id); +} + 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 5adae46..e99807c 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -18,6 +18,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, AbstractDatabaseClient { IceUtil::Optional findPackage(const std::string &, const std::string &, const Ice::Current &) override; Gentoo::Packages getPackagesInCategory(Ice::Int id, const Ice::Current &) override; Gentoo::SearchResultPackages getPackagesSearch(const std::string & query, const Ice::Current &) override; + Gentoo::Ebuilds getPackageVersions(Ice::Int id, const Ice::Current &) override; Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override; Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/sql/portage/getPackageVersions.sql b/gentoobrowse-api/service/sql/portage/getPackageVersions.sql new file mode 100644 index 0000000..90addae --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getPackageVersions.sql @@ -0,0 +1,4 @@ +SELECT e.ebuildid, e.packageid, e.repoid, e.version, e.slot, e.firstseen, e.moddate, e.license +FROM gentoobrowse.ebuilds e +WHERE e.packageid = ? +ORDER BY e.versioninst DESC diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 8242580..5f42bad 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -151,6 +151,23 @@ BOOST_AUTO_TEST_CASE( searchNotFound ) BOOST_REQUIRE(matches.empty()); } +BOOST_AUTO_TEST_CASE( getPackageVersions ) +{ + MockPool mp; + auto p = Portage::PointerType(new Portage(mp)); + auto es = p->getPackageVersions(58252); + BOOST_REQUIRE_EQUAL(9, es.size()); + BOOST_REQUIRE_EQUAL(634225, es.front()->ebuildid); + BOOST_REQUIRE_EQUAL(58252, es.front()->packageid); + BOOST_REQUIRE_EQUAL(17, es.front()->repoid); + BOOST_REQUIRE_EQUAL("5.20150731", es.front()->version); + BOOST_REQUIRE_EQUAL("0", es.front()->slot); + BOOST_REQUIRE_EQUAL("2015-08-10T18:11:55.489505", es.front()->firstseen); + BOOST_REQUIRE_EQUAL("2015-12-01T15:10:49", es.front()->moddate); + BOOST_REQUIRE_EQUAL("GPL-3", es.front()->license); + BOOST_REQUIRE_EQUAL(629067, es.back()->ebuildid); +} + BOOST_AUTO_TEST_CASE( getBug ) { MockPool mp; -- cgit v1.2.3