From 3b887671be52870d1bb402a487259d48b2dfd7d4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 12 Dec 2015 16:33:55 +0000 Subject: Add get recent additions --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + .../service/sql/portage/getRecentAdditions.sql | 8 ++++++++ gentoobrowse-api/unittests/testPortage.cpp | 16 ++++++++++++++++ 5 files changed, 33 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getRecentAdditions.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index faf8155..c70c146 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -14,6 +14,7 @@ module Gentoo { idempotent SearchResultPackages getPackagesSearch(string query); idempotent Ebuilds getPackageVersions(int id); idempotent ChangeLog getPackageChangeLog(int id); + idempotent Ebuilds getRecentAdditions(int syncs); 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 7cbfea7..c1a7f36 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,12 @@ Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &) return fetch(id); } +Gentoo::Ebuilds +Portage::getRecentAdditions(Ice::Int syncs, const Ice::Current &) +{ + return fetch(syncs); +} + 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 8624996..6bdcc2e 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -20,6 +20,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, AbstractDatabaseClient { Gentoo::SearchResultPackages getPackagesSearch(const std::string & query, const Ice::Current &) override; Gentoo::Ebuilds getPackageVersions(Ice::Int id, const Ice::Current &) override; Gentoo::ChangeLog getPackageChangeLog(Ice::Int id, const Ice::Current &) override; + Gentoo::Ebuilds getRecentAdditions(Ice::Int syncs, 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/getRecentAdditions.sql b/gentoobrowse-api/service/sql/portage/getRecentAdditions.sql new file mode 100644 index 0000000..ee2812a --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getRecentAdditions.sql @@ -0,0 +1,8 @@ +SELECT e.ebuildid, e.packageid, e.repoid, e.version, e.slot, e.firstseen, e.moddate, e.license +FROM gentoobrowse.ebuilds e +WHERE e.firstseen IN ( + SELECT DISTINCT s.firstseen + FROM gentoobrowse.ebuilds s + ORDER BY s.firstseen DESC + LIMIT ?) +ORDER BY e.firstseen, e.packageid diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 684390b..063b6a4 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -188,6 +188,22 @@ BOOST_AUTO_TEST_CASE( getPackageChangeLog ) BOOST_REQUIRE_EQUAL("revbump", cl.back()->comment); } +BOOST_AUTO_TEST_CASE( getRecentAdditions ) +{ + MockPool mp; + auto p = Portage::PointerType(new Portage(mp)); + auto es = p->getRecentAdditions(2); + BOOST_REQUIRE_EQUAL(8, es.size()); + BOOST_REQUIRE_EQUAL(680617, es.front()->ebuildid); + BOOST_REQUIRE_EQUAL(44063, es.front()->packageid); + BOOST_REQUIRE_EQUAL(17, es.front()->repoid); + BOOST_REQUIRE_EQUAL("3.6.2", es.front()->version); + BOOST_REQUIRE_EQUAL("0", es.front()->slot); + BOOST_REQUIRE_EQUAL("2015-12-02T19:12:42.627493", es.front()->firstseen); + BOOST_REQUIRE_EQUAL("2015-12-03T17:21:25", es.front()->moddate); + BOOST_REQUIRE_EQUAL("GPL-2", es.front()->license); +} + BOOST_AUTO_TEST_CASE( getBug ) { MockPool mp; -- cgit v1.2.3