summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/api/portage.ice1
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp7
-rw-r--r--gentoobrowse-api/service/portageimpl.h1
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageVersions.sql4
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp17
5 files changed, 30 insertions, 0 deletions
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 <sql/portage/findPackage.h>
#include <sql/portage/getPackagesInCategory.h>
#include <sql/portage/getPackagesSearch.h>
+#include <sql/portage/getPackageVersions.h>
#include <sql/portage/getBug.h>
#include <sql/portage/getPackageBugs.h>
#include <sql/portage/getBugsSearch.h>
@@ -64,6 +65,12 @@ Portage::getPackagesSearch(const std::string & query, const Ice::Current &)
return fetch<Gentoo::SearchResultPackages, sql::getPackagesSearch>(query, query);
}
+Gentoo::Ebuilds
+Portage::getPackageVersions(Ice::Int id, const Ice::Current &)
+{
+ return fetch<Gentoo::Ebuilds, sql::getPackageVersions>(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<Gentoo::PackagePtr> 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;