diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-12 16:33:55 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-12 16:33:55 +0000 |
commit | d96f76f6f97c4947d08af6715f08884ebd19ef37 (patch) | |
tree | 0273f1f484867756bc96cdb7929041b3713675a1 | |
parent | Switch lib64 references for native ones (diff) | |
download | gentoobrowse-api-d96f76f6f97c4947d08af6715f08884ebd19ef37.tar.bz2 gentoobrowse-api-d96f76f6f97c4947d08af6715f08884ebd19ef37.tar.xz gentoobrowse-api-d96f76f6f97c4947d08af6715f08884ebd19ef37.zip |
Add get recent additions
-rw-r--r-- | gentoobrowse-api/api/portage.ice | 1 | ||||
-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/getRecentAdditions.sql | 8 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testPortage.cpp | 16 |
5 files changed, 33 insertions, 0 deletions
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 <sql/portage/getPackagesSearch.h> #include <sql/portage/getPackageVersions.h> #include <sql/portage/getPackageChangeLog.h> +#include <sql/portage/getRecentAdditions.h> #include <sql/portage/getBug.h> #include <sql/portage/getPackageBugs.h> #include <sql/portage/getBugsSearch.h> @@ -78,6 +79,12 @@ Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &) return fetch<Gentoo::ChangeLog, sql::getPackageChangeLog>(id); } +Gentoo::Ebuilds +Portage::getRecentAdditions(Ice::Int syncs, const Ice::Current &) +{ + return fetch<Gentoo::Ebuilds, sql::getRecentAdditions>(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; |