From 46702be9bb2ba37b47f129c46f447368fde69123 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 11 Dec 2015 01:51:23 +0000 Subject: Get package change log --- gentoobrowse-api/api/portage.ice | 1 + gentoobrowse-api/domain/portage-models.ice | 11 +++++++++++ gentoobrowse-api/service/portageimpl.cpp | 7 +++++++ gentoobrowse-api/service/portageimpl.h | 1 + .../service/sql/portage/getPackageChangeLog.sql | 4 ++++ gentoobrowse-api/unittests/testPortage.cpp | 20 ++++++++++++++++++++ 6 files changed, 44 insertions(+) create mode 100644 gentoobrowse-api/service/sql/portage/getPackageChangeLog.sql diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice index 2101a76..faf8155 100644 --- a/gentoobrowse-api/api/portage.ice +++ b/gentoobrowse-api/api/portage.ice @@ -13,6 +13,7 @@ module Gentoo { idempotent Packages getPackagesInCategory(int id); idempotent SearchResultPackages getPackagesSearch(string query); idempotent Ebuilds getPackageVersions(int id); + idempotent ChangeLog getPackageChangeLog(int id); idempotent Bug getBug(int id); idempotent Bugs getPackageBugs(int packageId); diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice index c1257db..744cbf5 100644 --- a/gentoobrowse-api/domain/portage-models.ice +++ b/gentoobrowse-api/domain/portage-models.ice @@ -52,10 +52,21 @@ module Gentoo { string firstseen; }; + class ChangeLogEntry { + int packageid; + [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ] + string date; + string comment; + optional(0) string person; + optional(1) string email; + int repoid; + }; + sequence Categories; sequence Packages; sequence Ebuilds; sequence Bugs; + sequence ChangeLog; }; #endif diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index f2c593a..7cbfea7 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,12 @@ Portage::getPackageVersions(Ice::Int id, const Ice::Current &) return fetch(id); } +Gentoo::ChangeLog +Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &) +{ + return fetch(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 e99807c..8624996 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -19,6 +19,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, AbstractDatabaseClient { 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::ChangeLog getPackageChangeLog(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/getPackageChangeLog.sql b/gentoobrowse-api/service/sql/portage/getPackageChangeLog.sql new file mode 100644 index 0000000..0917b72 --- /dev/null +++ b/gentoobrowse-api/service/sql/portage/getPackageChangeLog.sql @@ -0,0 +1,4 @@ +SELECT cl.packageid, cl.date, cl.person, cl.email, cl.comment, cl.repoid +FROM gentoobrowse.package_changelogs cl +WHERE packageid = ? +ORDER BY cl.date DESC, cl.n DESC, cl.repoid diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 5f42bad..684390b 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -168,6 +168,26 @@ BOOST_AUTO_TEST_CASE( getPackageVersions ) BOOST_REQUIRE_EQUAL(629067, es.back()->ebuildid); } +BOOST_AUTO_TEST_CASE( getPackageChangeLog ) +{ + MockPool mp; + auto p = Portage::PointerType(new Portage(mp)); + auto cl = p->getPackageChangeLog(64582); + BOOST_REQUIRE_EQUAL(3, cl.size()); + BOOST_REQUIRE_EQUAL(64582, cl.front()->packageid); + BOOST_REQUIRE_EQUAL("2015-10-21T00:00:00", cl.front()->date); + BOOST_REQUIRE(cl.front()->email); + BOOST_REQUIRE_EQUAL("jlec@gentoo.org", *cl.front()->email); + BOOST_REQUIRE(cl.front()->person); + BOOST_REQUIRE_EQUAL("Justin Lecher", *cl.front()->person); + BOOST_REQUIRE_EQUAL("Update remote-ids", cl.front()->comment); + BOOST_REQUIRE_EQUAL(17, cl.front()->repoid); + BOOST_REQUIRE_EQUAL("2015-10-17T00:00:00", cl.back()->date); + BOOST_REQUIRE(cl.back()->email); + BOOST_REQUIRE_EQUAL("tomboy64@sina.cn", *cl.back()->email); + BOOST_REQUIRE_EQUAL("revbump", cl.back()->comment); +} + BOOST_AUTO_TEST_CASE( getBug ) { MockPool mp; -- cgit v1.2.3