From 676047b646aebb5e48d8b93d66401f9469114ea4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Sep 2016 23:44:53 +0100 Subject: Add method for getting ebuilds with details (archs and uses) --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/domain/extended-models.ice | 6 ++++++ gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + .../service/sql/portage/getPackageVersionDetails.sql | 6 ++++++ gentoobrowse-api/unittests/testPortage.cpp | 17 +++++++++++++++++ 6 files changed, 38 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getPackageVersionDetails.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index 584aee5..aed2293 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -17,6 +17,7 @@ module Gentoo { idempotent Packages getPackagesInCategory(int id); idempotent SearchResultPackages getPackagesSearch(string query); idempotent Ebuilds getPackageVersions(int id); + idempotent EbuildDetails getPackageVersionDetails(int id); idempotent ChangeLog getPackageChangeLog(int id); idempotent Syncs getSyncs(int syncs); idempotent Ebuilds getRecentAdditions(int syncs); diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice index f030361..fabf0f3 100644 --- a/gentoobrowse-api/domain/extended-models.ice +++ b/gentoobrowse-api/domain/extended-models.ice @@ -18,9 +18,15 @@ module Gentoo { double rank; }; + class EbuildDetail extends Ebuild { + StringList uses; + StringList archs; + }; + sequence SearchResultPackages; sequence SearchResultBugs; sequence OverviewCategories; + sequence EbuildDetails; dictionary OverviewCategoriesBySuper; }; diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 2147307..9854230 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,12 @@ Portage::getPackageVersions(Ice::Int id, const Ice::Current &) return fetchCache(sql::portage::getPackageVersions, 30, id); } +Gentoo::EbuildDetails +Portage::getPackageVersionDetails(Ice::Int id, const Ice::Current &) +{ + return fetchCache(sql::portage::getPackageVersionDetails, 30, id); +} + Gentoo::ChangeLog Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &) { diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h index 17c30af..86608d5 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -24,6 +24,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab Gentoo::Packages getAllPackages(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::EbuildDetails getPackageVersionDetails(Ice::Int id, const Ice::Current &) override; Gentoo::ChangeLog getPackageChangeLog(Ice::Int id, const Ice::Current &) override; Gentoo::Syncs getSyncs(Ice::Int syncs, const Ice::Current &) override; Gentoo::Ebuilds getRecentAdditions(Ice::Int syncs, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/sql/portage/getPackageVersionDetails.sql b/gentoobrowse-api/service/sql/portage/getPackageVersionDetails.sql new file mode 100644 index 0000000..5e44e30 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getPackageVersionDetails.sql @@ -0,0 +1,6 @@ +SELECT e.ebuildid, e.packageid, e.repoid, e.version, e.slot, e.firstseen, e.moddate, e.license, + (SELECT ARRAY_AGG(use ORDER BY use) FROM gentoobrowse.ebuild_uses u WHERE u.ebuildid = e.ebuildid) uses, + (SELECT ARRAY_AGG(arch ORDER BY arch) FROM gentoobrowse.ebuild_archs a WHERE a.ebuildid = e.ebuildid) archs +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 9cdbd1f..263c707 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -204,6 +204,23 @@ BOOST_AUTO_TEST_CASE( getPackageVersions ) BOOST_REQUIRE_EQUAL(629067, es.back()->ebuildid); } +BOOST_AUTO_TEST_CASE( getPackageVersionDetails ) +{ + auto es = p->getPackageVersionDetails(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_REQUIRE_EQUAL(21, es.front()->uses.size()); + BOOST_REQUIRE_EQUAL(3, es.front()->archs.size()); +} + BOOST_AUTO_TEST_CASE( getPackageChangeLog ) { auto cl = p->getPackageChangeLog(64582); -- cgit v1.2.3