summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-09 03:47:01 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-09 03:47:01 +0000
commitaf28992bce1383e1bd1bf3f370c2bcd708d74144 (patch)
tree86f25b1c904bf7a9b7d7a3577c06376782864ac5
parentTurn the client into an extensible app, starting with package search (diff)
downloadgentoobrowse-api-af28992bce1383e1bd1bf3f370c2bcd708d74144.tar.bz2
gentoobrowse-api-af28992bce1383e1bd1bf3f370c2bcd708d74144.tar.xz
gentoobrowse-api-af28992bce1383e1bd1bf3f370c2bcd708d74144.zip
Add bugs list support
-rw-r--r--gentoobrowse-api/api/portage.ice4
-rw-r--r--gentoobrowse-api/domain/extended-models.ice5
-rw-r--r--gentoobrowse-api/domain/portage-models.ice9
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp21
-rw-r--r--gentoobrowse-api/service/portageimpl.h4
-rw-r--r--gentoobrowse-api/service/sql/portage/getBug.sql3
-rw-r--r--gentoobrowse-api/service/sql/portage/getBugsSearch.sql5
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageBugs.sql5
-rw-r--r--gentoobrowse-api/unittests/fixtures/package_bugs.dat2
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp33
10 files changed, 91 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index 9ac9899..00f4730 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -12,6 +12,10 @@ module Gentoo {
idempotent optional(0) Package findPackage(string category, string package);
idempotent Packages getPackagesInCategory(int id);
idempotent SearchResultPackages getPackagesSearch(string query);
+
+ idempotent Bug getBug(int id);
+ idempotent Bugs getPackageBugs(int packageId);
+ idempotent SearchResultBugs getBugsSearch(string query);
};
};
diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice
index 956692f..cccd45a 100644
--- a/gentoobrowse-api/domain/extended-models.ice
+++ b/gentoobrowse-api/domain/extended-models.ice
@@ -12,7 +12,12 @@ module Gentoo {
double rank;
};
+ class SearchResultBug extends Bug {
+ double rank;
+ };
+
sequence<SearchResultPackage> SearchResultPackages;
+ sequence<SearchResultBug> SearchResultBugs;
sequence<OverviewCategory> OverviewCategories;
};
diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice
index 9593315..2efe985 100644
--- a/gentoobrowse-api/domain/portage-models.ice
+++ b/gentoobrowse-api/domain/portage-models.ice
@@ -34,9 +34,18 @@ module Gentoo {
optional(1) string license;
};
+ class Bug {
+ ["slicer:db:pkey"]
+ int bugid;
+ string severity;
+ string status;
+ string summary;
+ };
+
sequence<Category> Categories;
sequence<Package> Packages;
sequence<Ebuild> Ebuilds;
+ sequence<Bug> Bugs;
};
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index f7881fa..9e495e2 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -7,6 +7,9 @@
#include <sql/portage/findPackage.h>
#include <sql/portage/getPackagesInCategory.h>
#include <sql/portage/getPackagesSearch.h>
+#include <sql/portage/getBug.h>
+#include <sql/portage/getPackageBugs.h>
+#include <sql/portage/getBugsSearch.h>
Portage::Portage(AdHoc::ResourcePool<DB::Connection> & d) :
AbstractDatabaseClient(d)
@@ -61,3 +64,21 @@ Portage::getPackagesSearch(const std::string & query, const Ice::Current &)
return fetch<Gentoo::SearchResultPackages, sql::getPackagesSearch>(query, query);
}
+Gentoo::BugPtr
+Portage::getBug(Ice::Int id, const Ice::Current &)
+{
+ return fetch<Gentoo::BugPtr, sql::getBug>(id);
+}
+
+Gentoo::Bugs
+Portage::getPackageBugs(Ice::Int packageId, const Ice::Current &)
+{
+ return fetch<Gentoo::Bugs, sql::getPackageBugs>(packageId);
+}
+
+Gentoo::SearchResultBugs
+Portage::getBugsSearch(const std::string & query, const Ice::Current &)
+{
+ return fetch<Gentoo::SearchResultBugs, sql::getBugsSearch>(query, query);
+}
+
diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h
index f72fee2..5adae46 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -18,6 +18,10 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, AbstractDatabaseClient {
IceUtil::Optional<Gentoo::PackagePtr> findPackage(const std::string &, const std::string &, const Ice::Current &) override;
Gentoo::Packages getPackagesInCategory(Ice::Int id, const Ice::Current &) override;
Gentoo::SearchResultPackages getPackagesSearch(const std::string & query, const Ice::Current &) override;
+
+ 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;
};
#endif
diff --git a/gentoobrowse-api/service/sql/portage/getBug.sql b/gentoobrowse-api/service/sql/portage/getBug.sql
new file mode 100644
index 0000000..b91b1a6
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getBug.sql
@@ -0,0 +1,3 @@
+SELECT b.bugid, b.severity, b.status, b.summary
+FROM gentoobrowse.bugs b
+WHERE b.bugid = ?
diff --git a/gentoobrowse-api/service/sql/portage/getBugsSearch.sql b/gentoobrowse-api/service/sql/portage/getBugsSearch.sql
new file mode 100644
index 0000000..856dc7b
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getBugsSearch.sql
@@ -0,0 +1,5 @@
+SELECT b.bugid, b.severity, b.status, b.summary,
+ ts_rank(gentoobrowse.bugfts(b), plainto_tsquery('english', ?)) rank
+FROM gentoobrowse.bugs b
+WHERE gentoobrowse.bugfts(b) @@ plainto_tsquery('english', ?)
+ORDER BY rank DESC, bugid
diff --git a/gentoobrowse-api/service/sql/portage/getPackageBugs.sql b/gentoobrowse-api/service/sql/portage/getPackageBugs.sql
new file mode 100644
index 0000000..ed9cee8
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackageBugs.sql
@@ -0,0 +1,5 @@
+SELECT b.bugid, b.severity, b.status, b.summary
+FROM gentoobrowse.bugs b, gentoobrowse.package_bugs pb
+WHERE b.bugid = pb.bugid
+AND pb.packageid = ?
+ORDER BY b.bugid
diff --git a/gentoobrowse-api/unittests/fixtures/package_bugs.dat b/gentoobrowse-api/unittests/fixtures/package_bugs.dat
index e69de29..3ef448f 100644
--- a/gentoobrowse-api/unittests/fixtures/package_bugs.dat
+++ b/gentoobrowse-api/unittests/fixtures/package_bugs.dat
@@ -0,0 +1,2 @@
+55923 567108 2010-06-19 14:36:57.532747
+55925 567166 2010-06-19 14:36:57.532747
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index a0b62a8..b6fa56a 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -150,6 +150,39 @@ BOOST_AUTO_TEST_CASE( searchNotFound )
BOOST_REQUIRE(matches.empty());
}
+BOOST_AUTO_TEST_CASE( getBug )
+{
+ MockPool mp;
+ auto p = Portage::PointerType(new Portage(mp));
+ auto b = p->getBug(567064);
+ BOOST_REQUIRE(b);
+ BOOST_REQUIRE_EQUAL(567064, b->bugid);
+ BOOST_REQUIRE_EQUAL("normal", b->severity);
+ BOOST_REQUIRE_EQUAL("UNCONFIRMED", b->status);
+ BOOST_REQUIRE_EQUAL("Request for new package: dev-python/twine", b->summary);
+}
+
+BOOST_AUTO_TEST_CASE( getPackageBugs )
+{
+ MockPool mp;
+ auto p = Portage::PointerType(new Portage(mp));
+ auto bs = p->getPackageBugs(55925);
+ BOOST_REQUIRE_EQUAL(1, bs.size());
+ BOOST_REQUIRE_EQUAL(567166, bs.front()->bugid);
+}
+
+BOOST_AUTO_TEST_CASE( getBugsSearch )
+{
+ MockPool mp;
+ auto p = Portage::PointerType(new Portage(mp));
+ auto bs = p->getBugsSearch("cpu");
+ BOOST_REQUIRE_EQUAL(3, bs.size());
+ BOOST_REQUIRE_EQUAL(567154, bs[0]->bugid);
+ BOOST_REQUIRE_CLOSE(0.06, bs[0]->rank, 2.0);
+ BOOST_REQUIRE_EQUAL(567250, bs[1]->bugid);
+ BOOST_REQUIRE_EQUAL(567682, bs[2]->bugid);
+}
+
BOOST_AUTO_TEST_CASE( cache )
{
MockPool mp;