diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-26 23:44:53 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-26 23:44:53 +0100 |
commit | 2de78773b1fefafcafbc16ba1de4c17e31932009 (patch) | |
tree | 58d3e824885a25ea4b7685a3b876a5235201050f | |
parent | Use a custom model part to read string lists in bulk from the DB (diff) | |
download | gentoobrowse-api-2de78773b1fefafcafbc16ba1de4c17e31932009.tar.bz2 gentoobrowse-api-2de78773b1fefafcafbc16ba1de4c17e31932009.tar.xz gentoobrowse-api-2de78773b1fefafcafbc16ba1de4c17e31932009.zip |
Add method for getting ebuilds with details (archs and uses)
-rw-r--r-- | gentoobrowse-api/api/portage.ice | 1 | ||||
-rw-r--r-- | gentoobrowse-api/domain/extended-models.ice | 6 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.cpp | 7 | ||||
-rw-r--r-- | gentoobrowse-api/service/portageimpl.h | 1 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/portage/getPackageVersionDetails.sql | 6 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 17 |
6 files changed, 38 insertions, 0 deletions
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<SearchResultPackage> SearchResultPackages; sequence<SearchResultBug> SearchResultBugs; sequence<OverviewCategory> OverviewCategories; + sequence<EbuildDetail> EbuildDetails; dictionary<string, OverviewCategories> 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 <sql/portage/getPackagesInCategory.sql.h> #include <sql/portage/getPackagesSearch.sql.h> #include <sql/portage/getPackageVersions.sql.h> +#include <sql/portage/getPackageVersionDetails.sql.h> #include <sql/portage/getPackageChangeLog.sql.h> #include <sql/portage/getPackagesWithRecentAdditions.sql.h> #include <sql/portage/getTopTrackedPackages.sql.h> @@ -109,6 +110,12 @@ Portage::getPackageVersions(Ice::Int id, const Ice::Current &) return fetchCache<Gentoo::Ebuilds>(sql::portage::getPackageVersions, 30, id); } +Gentoo::EbuildDetails +Portage::getPackageVersionDetails(Ice::Int id, const Ice::Current &) +{ + return fetchCache<Gentoo::EbuildDetails>(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); |