summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-19 21:05:22 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-19 21:05:22 +0000
commit59ac197145142196b3a90295b7ab1ea5de523ff8 (patch)
tree94bfc9819205b26c9f4bab06210c36d298f7eb5e
parentAdd support for unpacking PostgreSQL text arrays from their string form (diff)
downloadgentoobrowse-api-59ac197145142196b3a90295b7ab1ea5de523ff8.tar.bz2
gentoobrowse-api-59ac197145142196b3a90295b7ab1ea5de523ff8.tar.xz
gentoobrowse-api-59ac197145142196b3a90295b7ab1ea5de523ff8.zip
Add support for getting a news item by Id
-rw-r--r--gentoobrowse-api/api/portage.ice2
-rw-r--r--gentoobrowse-api/domain/portage-models.ice16
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp7
-rw-r--r--gentoobrowse-api/service/portageimpl.h2
-rw-r--r--gentoobrowse-api/service/sql/portage/getNewsItem.sql3
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp28
6 files changed, 58 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index c70c146..7e1eb43 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -19,6 +19,8 @@ module Gentoo {
idempotent Bug getBug(int id);
idempotent Bugs getPackageBugs(int packageId);
idempotent SearchResultBugs getBugsSearch(string query);
+
+ idempotent NewsItem getNewsItem(string newsid);
};
};
diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice
index 4f98ce3..b5a75c9 100644
--- a/gentoobrowse-api/domain/portage-models.ice
+++ b/gentoobrowse-api/domain/portage-models.ice
@@ -63,6 +63,22 @@ module Gentoo {
int repoid;
};
+ class NewsItem {
+ ["slicer:db:pkey"]
+ string newsid;
+ string title;
+ [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ]
+ string posted;
+ [ "slicer:conversion:std.string:unpackPqTextArray:packPqTextArray" ]
+ StringList body;
+ optional(0) string authorname;
+ optional(1) string authoremail;
+ [ "slicer:conversion:std.string:unpackPqTextArray:packPqTextArray" ]
+ StringList atomspec;
+ [ "slicer:conversion:std.string:unpackPqTextArray:packPqTextArray" ]
+ StringList urls;
+ };
+
sequence<Category> Categories;
sequence<Package> Packages;
sequence<Ebuild> Ebuilds;
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index c1a7f36..b199934 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -13,6 +13,7 @@
#include <sql/portage/getBug.h>
#include <sql/portage/getPackageBugs.h>
#include <sql/portage/getBugsSearch.h>
+#include <sql/portage/getNewsItem.h>
Portage::Portage(AdHoc::ResourcePool<DB::Connection> & d) :
AbstractDatabaseClient(d)
@@ -103,3 +104,9 @@ Portage::getBugsSearch(const std::string & query, const Ice::Current &)
return fetch<Gentoo::SearchResultBugs, sql::getBugsSearch>(query, query);
}
+Gentoo::NewsItemPtr
+Portage::getNewsItem(const std::string & id, const Ice::Current &)
+{
+ return fetch<Gentoo::NewsItemPtr, sql::getNewsItem>(id);
+}
+
diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h
index 6bdcc2e..9588095 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -25,6 +25,8 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, AbstractDatabaseClient {
Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override;
Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override;
Gentoo::SearchResultBugs getBugsSearch(const std::string & query, const Ice::Current &) override;
+
+ Gentoo::NewsItemPtr getNewsItem(const std::string &, const Ice::Current &) override;
};
#endif
diff --git a/gentoobrowse-api/service/sql/portage/getNewsItem.sql b/gentoobrowse-api/service/sql/portage/getNewsItem.sql
new file mode 100644
index 0000000..d69aa6a
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getNewsItem.sql
@@ -0,0 +1,3 @@
+SELECT n.newsid, n.title, n.posted, n.authorname, n.authoremail, n.body, n.atomspec, n.urls
+FROM gentoobrowse.news n
+WHERE n.newsid = ?
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index 063b6a4..8a8d5bb 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -240,6 +240,34 @@ BOOST_AUTO_TEST_CASE( getBugsSearch )
BOOST_REQUIRE_EQUAL(567682, bs[2]->bugid);
}
+BOOST_AUTO_TEST_CASE( getNewsItem )
+{
+ MockPool mp;
+ auto p = Portage::PointerType(new Portage(mp));
+ auto n = p->getNewsItem("2015-02-01-use-libav");
+ BOOST_REQUIRE(n);
+ BOOST_REQUIRE_EQUAL("2015-02-01-use-libav", n->newsid);
+ BOOST_REQUIRE_EQUAL("ffmpeg/libav conflict management: USE=libav", n->title);
+ BOOST_REQUIRE_EQUAL("2015-02-01T00:00:00", n->posted);
+ BOOST_REQUIRE(n->authorname);
+ BOOST_REQUIRE_EQUAL("Michał Górny", *n->authorname);
+ BOOST_REQUIRE(n->authoremail);
+ BOOST_REQUIRE_EQUAL("mgorny@gentoo.org", *n->authoremail);
+ BOOST_REQUIRE_EQUAL(2, n->atomspec.size());
+ BOOST_REQUIRE_EQUAL("media-video/ffmpeg", n->atomspec.front());
+ BOOST_REQUIRE_EQUAL("media-video/libav", n->atomspec.back());
+ BOOST_REQUIRE_EQUAL(5, n->body.size());
+ BOOST_REQUIRE_EQUAL("The support for automatic choice between ffmpeg and libav is going to be deprecated in favor of explicit choice via USE flags. This change aims to solve multiple repeating issues, including Portage undesirably wanting to replace one package with the other, lack of proper reverse dependency on ffmpeg/libav upgrades and some of the hard-to-understand upgrade failures involving blockers. It also may be used to make ffmpeg and libav co-installable in the future.", n->body.front());
+ BOOST_REQUIRE_EQUAL("Please do not alter the state of 'libav' flag on a per-package basis (e.g. via package.use). The flag needs to be set globally to have consistent value throughout all packages. Otherwise, blockers will prevent upgrades.", n->body.back());
+ BOOST_REQUIRE_EQUAL(0, n->urls.size());
+
+ auto n2 = p->getNewsItem("2014-10-26-gcc_4_7_introduced_new_c++11_abi");
+ BOOST_REQUIRE(n2);
+ BOOST_REQUIRE_EQUAL("2014-10-26-gcc_4_7_introduced_new_c++11_abi", n2->newsid);
+ BOOST_REQUIRE_EQUAL(1, n2->urls.size());
+ BOOST_REQUIRE_EQUAL("http://ispras.linuxbase.org/index.php/ABI_compliance_checker", n2->urls.front());
+}
+
BOOST_AUTO_TEST_CASE( cache )
{
MockPool mp;