summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/api/portage.ice7
-rw-r--r--gentoobrowse-api/domain/extended-models.ice3
-rw-r--r--gentoobrowse-api/domain/portage-models.ice7
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp60
-rw-r--r--gentoobrowse-api/service/portageimpl.h7
-rw-r--r--gentoobrowse-api/service/sql/portage/findCategory.sql3
-rw-r--r--gentoobrowse-api/service/sql/portage/getAllOverviewCategories.sql6
-rw-r--r--gentoobrowse-api/service/sql/portage/getAllPackages.sql3
-rw-r--r--gentoobrowse-api/service/sql/portage/getCategoriesWithRecentAdditions.sql11
-rw-r--r--gentoobrowse-api/service/sql/portage/getOverviewCategoriesInSuper.sql2
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackagesWithRecentAdditions.sql10
-rw-r--r--gentoobrowse-api/service/sql/portage/getSyncs.sql5
-rw-r--r--gentoobrowse-api/service/sql/portage/getTopTrackedPackages.sql6
-rw-r--r--gentoobrowse-api/unittests/fixtures/user_packages.dat3
-rw-r--r--gentoobrowse-api/unittests/fixtures/users.dat1
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp65
16 files changed, 198 insertions, 1 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index 9479eff..56d066b 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -4,17 +4,24 @@
module Gentoo {
interface Portage {
idempotent Category getCategory(int id);
+ idempotent Category findCategory(string name);
idempotent Categories getAllCategories();
idempotent Categories getCategoriesInSuper(string super);
+ idempotent OverviewCategoriesBySuper getAllOverviewCategories();
idempotent OverviewCategories getOverviewCategoriesInSuper(string super);
idempotent Package getPackage(int id);
idempotent optional(0) Package findPackage(string category, string package);
+ idempotent Packages getAllPackages();
idempotent Packages getPackagesInCategory(int id);
idempotent SearchResultPackages getPackagesSearch(string query);
idempotent Ebuilds getPackageVersions(int id);
idempotent ChangeLog getPackageChangeLog(int id);
+ idempotent Syncs getSyncs(int syncs);
idempotent Ebuilds getRecentAdditions(int syncs);
+ idempotent Packages getPackagesWithRecentAdditions(int syncs);
+ idempotent Categories getCategoriesWithRecentAdditions(int syncs);
+ idempotent Packages getTopTrackedPackages(int n);
idempotent Bug getBug(int id);
idempotent Bugs getPackageBugs(int packageId);
diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice
index cccd45a..f030361 100644
--- a/gentoobrowse-api/domain/extended-models.ice
+++ b/gentoobrowse-api/domain/extended-models.ice
@@ -6,6 +6,8 @@
module Gentoo {
class OverviewCategory extends Category {
int packagecount;
+ [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ]
+ string lastaddition;
};
class SearchResultPackage extends Package {
@@ -19,6 +21,7 @@ module Gentoo {
sequence<SearchResultPackage> SearchResultPackages;
sequence<SearchResultBug> SearchResultBugs;
sequence<OverviewCategory> OverviewCategories;
+ dictionary<string, OverviewCategories> OverviewCategoriesBySuper;
};
#endif
diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice
index d15194e..dc4a57e 100644
--- a/gentoobrowse-api/domain/portage-models.ice
+++ b/gentoobrowse-api/domain/portage-models.ice
@@ -91,12 +91,19 @@ module Gentoo {
StringList use;
};
+ struct Sync {
+ [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ]
+ string timestamp;
+ int ebuilds;
+ };
+
sequence<Category> Categories;
sequence<Package> Packages;
sequence<Ebuild> Ebuilds;
sequence<Bug> Bugs;
sequence<ChangeLogEntry> ChangeLog;
sequence<NewsItem> News;
+ sequence<Sync> Syncs;
};
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index 1a5b96c..7653976 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -1,15 +1,22 @@
#include "portageimpl.h"
#include <sql/portage/getCategory.sql.h>
+#include <sql/portage/findCategory.sql.h>
#include <sql/portage/getAllCategories.sql.h>
#include <sql/portage/getCategoriesInSuper.sql.h>
+#include <sql/portage/getCategoriesWithRecentAdditions.sql.h>
#include <sql/portage/getOverviewCategoriesInSuper.sql.h>
+#include <sql/portage/getAllOverviewCategories.sql.h>
#include <sql/portage/getPackage.sql.h>
#include <sql/portage/findPackage.sql.h>
+#include <sql/portage/getAllPackages.sql.h>
#include <sql/portage/getPackagesInCategory.sql.h>
#include <sql/portage/getPackagesSearch.sql.h>
#include <sql/portage/getPackageVersions.sql.h>
#include <sql/portage/getPackageChangeLog.sql.h>
+#include <sql/portage/getPackagesWithRecentAdditions.sql.h>
+#include <sql/portage/getTopTrackedPackages.sql.h>
#include <sql/portage/getRecentAdditions.sql.h>
+#include <sql/portage/getSyncs.sql.h>
#include <sql/portage/getBug.sql.h>
#include <sql/portage/getPackageBugs.sql.h>
#include <sql/portage/getBugsSearch.sql.h>
@@ -30,6 +37,12 @@ Portage::getCategory(Ice::Int id, const Ice::Current &)
return fetchCache<Gentoo::CategoryPtr>(sql::portage::getCategory, 30, id);
}
+Gentoo::CategoryPtr
+Portage::findCategory(const std::string & name, const Ice::Current &)
+{
+ return fetchCache<Gentoo::CategoryPtr>(sql::portage::findCategory, 30, name);
+}
+
Gentoo::Categories
Portage::getAllCategories(const Ice::Current &)
{
@@ -42,6 +55,23 @@ Portage::getCategoriesInSuper(const std::string & super, const Ice::Current &)
return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesInSuper, 30, super);
}
+Gentoo::OverviewCategoriesBySuper
+Portage::getAllOverviewCategories(const Ice::Current &)
+{
+ Gentoo::OverviewCategoriesBySuper rtn;
+ auto cats = fetchCache<Gentoo::OverviewCategories>(sql::portage::getAllOverviewCategories, 30);
+ for (const auto & c : cats) {
+ auto hyphen = c->name.find('-');
+ if (hyphen == (std::string::npos)-1) {
+ rtn[c->name].push_back(c);
+ }
+ else {
+ rtn[c->name.substr(0, hyphen)].push_back(c);
+ }
+ }
+ return rtn;
+}
+
Gentoo::OverviewCategories
Portage::getOverviewCategoriesInSuper(const std::string & super, const Ice::Current &)
{
@@ -61,6 +91,12 @@ Portage::findPackage(const std::string & cat, const std::string & pkg, const Ice
}
Gentoo::Packages
+Portage::getAllPackages(const Ice::Current &)
+{
+ return fetchCache<Gentoo::Packages>(sql::portage::getAllPackages, 30);
+}
+
+Gentoo::Packages
Portage::getPackagesInCategory(Ice::Int id, const Ice::Current &)
{
return fetchCache<Gentoo::Packages>(sql::portage::getPackagesInCategory, 30, id);
@@ -84,12 +120,36 @@ Portage::getPackageChangeLog(Ice::Int id, const Ice::Current &)
return fetchCache<Gentoo::ChangeLog>(sql::portage::getPackageChangeLog, 30, id);
}
+Gentoo::Syncs
+Portage::getSyncs(Ice::Int syncs, const Ice::Current &)
+{
+ return fetchCache<Gentoo::Syncs>(sql::portage::getSyncs, 30, syncs);
+}
+
Gentoo::Ebuilds
Portage::getRecentAdditions(Ice::Int syncs, const Ice::Current &)
{
return fetchCache<Gentoo::Ebuilds>(sql::portage::getRecentAdditions, 30, syncs);
}
+Gentoo::Packages
+Portage::getPackagesWithRecentAdditions(Ice::Int syncs, const Ice::Current &)
+{
+ return fetchCache<Gentoo::Packages>(sql::portage::getPackagesWithRecentAdditions, 30, syncs);
+}
+
+Gentoo::Packages
+Portage::getTopTrackedPackages(Ice::Int n, const Ice::Current &)
+{
+ return fetchCache<Gentoo::Packages>(sql::portage::getTopTrackedPackages, 30, n);
+}
+
+Gentoo::Categories
+Portage::getCategoriesWithRecentAdditions(Ice::Int syncs, const Ice::Current &)
+{
+ return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesWithRecentAdditions, 30, 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 d47941b..273fbed 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -12,17 +12,24 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab
Portage(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d);
Gentoo::CategoryPtr getCategory(Ice::Int id, const Ice::Current &) override;
+ Gentoo::CategoryPtr findCategory(const std::string & name, const Ice::Current &) override;
Gentoo::Categories getAllCategories(const Ice::Current &) override;
Gentoo::Categories getCategoriesInSuper(const std::string &, const Ice::Current &) override;
+ Gentoo::OverviewCategoriesBySuper getAllOverviewCategories(const Ice::Current &) override;
Gentoo::OverviewCategories getOverviewCategoriesInSuper(const std::string &, const Ice::Current &) override;
Gentoo::PackagePtr getPackage(Ice::Int id, const Ice::Current &) override;
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::Packages getAllPackages(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::Syncs getSyncs(Ice::Int syncs, const Ice::Current &) override;
Gentoo::Ebuilds getRecentAdditions(Ice::Int syncs, const Ice::Current &) override;
+ Gentoo::Packages getPackagesWithRecentAdditions(Ice::Int syncs, const Ice::Current &) override;
+ Gentoo::Categories getCategoriesWithRecentAdditions(Ice::Int syncs, const Ice::Current &) override;
+ Gentoo::Packages getTopTrackedPackages(Ice::Int n, 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/findCategory.sql b/gentoobrowse-api/service/sql/portage/findCategory.sql
new file mode 100644
index 0000000..b1cb130
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/findCategory.sql
@@ -0,0 +1,3 @@
+SELECT c.categoryid, c.name, c.summary
+FROM gentoobrowse.categories c
+WHERE c.name = ?
diff --git a/gentoobrowse-api/service/sql/portage/getAllOverviewCategories.sql b/gentoobrowse-api/service/sql/portage/getAllOverviewCategories.sql
new file mode 100644
index 0000000..d4b72c8
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getAllOverviewCategories.sql
@@ -0,0 +1,6 @@
+SELECT c.categoryid, c.name, c.summary, COUNT(p.packageid) packagecount, MAX(p.firstseen) lastaddition
+FROM gentoobrowse.categories c
+ LEFT OUTER JOIN gentoobrowse.packages p
+ ON p.categoryid = c.categoryid
+GROUP BY c.categoryid
+ORDER BY c.name
diff --git a/gentoobrowse-api/service/sql/portage/getAllPackages.sql b/gentoobrowse-api/service/sql/portage/getAllPackages.sql
new file mode 100644
index 0000000..fc8fe6d
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getAllPackages.sql
@@ -0,0 +1,3 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd
+FROM gentoobrowse.packages p
+ORDER BY p.categoryid, p.name
diff --git a/gentoobrowse-api/service/sql/portage/getCategoriesWithRecentAdditions.sql b/gentoobrowse-api/service/sql/portage/getCategoriesWithRecentAdditions.sql
new file mode 100644
index 0000000..4007bf2
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getCategoriesWithRecentAdditions.sql
@@ -0,0 +1,11 @@
+SELECT c.categoryid, c.name, c.summary
+FROM gentoobrowse.categories c, gentoobrowse.packages p, gentoobrowse.ebuilds e
+WHERE c.categoryid = p.categoryid
+AND p.packageid = e.packageid
+AND e.firstseen IN (
+ SELECT DISTINCT s.firstseen
+ FROM gentoobrowse.ebuilds s
+ ORDER BY s.firstseen DESC
+ LIMIT ?)
+GROUP BY c.categoryid
+ORDER BY c.categoryid
diff --git a/gentoobrowse-api/service/sql/portage/getOverviewCategoriesInSuper.sql b/gentoobrowse-api/service/sql/portage/getOverviewCategoriesInSuper.sql
index e971aed..876e551 100644
--- a/gentoobrowse-api/service/sql/portage/getOverviewCategoriesInSuper.sql
+++ b/gentoobrowse-api/service/sql/portage/getOverviewCategoriesInSuper.sql
@@ -1,4 +1,4 @@
-SELECT c.categoryid, c.name, c.summary, COUNT(p.packageid) packagecount
+SELECT c.categoryid, c.name, c.summary, COUNT(p.packageid) packagecount, MAX(p.firstseen) lastaddition
FROM gentoobrowse.categories c
LEFT OUTER JOIN gentoobrowse.packages p
ON p.categoryid = c.categoryid
diff --git a/gentoobrowse-api/service/sql/portage/getPackagesWithRecentAdditions.sql b/gentoobrowse-api/service/sql/portage/getPackagesWithRecentAdditions.sql
new file mode 100644
index 0000000..052da8d
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackagesWithRecentAdditions.sql
@@ -0,0 +1,10 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd
+FROM gentoobrowse.packages p, gentoobrowse.ebuilds e
+WHERE p.packageid = e.packageid
+AND e.firstseen IN (
+ SELECT DISTINCT s.firstseen
+ FROM gentoobrowse.ebuilds s
+ ORDER BY s.firstseen DESC
+ LIMIT ?)
+GROUP BY p.packageid
+ORDER BY p.packageid
diff --git a/gentoobrowse-api/service/sql/portage/getSyncs.sql b/gentoobrowse-api/service/sql/portage/getSyncs.sql
new file mode 100644
index 0000000..eef5e3e
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getSyncs.sql
@@ -0,0 +1,5 @@
+SELECT s.firstseen AS timestamp, COUNT(*) AS ebuilds
+FROM gentoobrowse.ebuilds s
+GROUP BY s.firstseen
+ORDER BY s.firstseen DESC
+LIMIT ?
diff --git a/gentoobrowse-api/service/sql/portage/getTopTrackedPackages.sql b/gentoobrowse-api/service/sql/portage/getTopTrackedPackages.sql
new file mode 100644
index 0000000..c328d73
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getTopTrackedPackages.sql
@@ -0,0 +1,6 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd
+FROM gentoobrowse.packages p, gentoobrowse.user_packages up
+WHERE p.packageid = up.packageid
+GROUP BY p.packageid
+ORDER BY COUNT(*) DESC
+LIMIT ?
diff --git a/gentoobrowse-api/unittests/fixtures/user_packages.dat b/gentoobrowse-api/unittests/fixtures/user_packages.dat
index e69de29..2a87d43 100644
--- a/gentoobrowse-api/unittests/fixtures/user_packages.dat
+++ b/gentoobrowse-api/unittests/fixtures/user_packages.dat
@@ -0,0 +1,3 @@
+1 49517 2010-08-12 15:50:47.72758
+1 54144 2014-12-10 23:00:13.500634
+1 55943 2013-07-29 22:47:58.538607
diff --git a/gentoobrowse-api/unittests/fixtures/users.dat b/gentoobrowse-api/unittests/fixtures/users.dat
index e69de29..4544513 100644
--- a/gentoobrowse-api/unittests/fixtures/users.dat
+++ b/gentoobrowse-api/unittests/fixtures/users.dat
@@ -0,0 +1 @@
+1 randomdan Dan Goodliffe p@55w0rd dan@randomdan.homeip.net \N
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index 90ad707..2a8dd77 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -22,6 +22,16 @@ BOOST_AUTO_TEST_CASE( getCategory )
BOOST_REQUIRE_EQUAL(169, cat->summary->length());
}
+BOOST_AUTO_TEST_CASE( findCategory )
+{
+ auto cat = p->findCategory("app-backup");
+ BOOST_REQUIRE(cat);
+ BOOST_REQUIRE_EQUAL(316, cat->categoryid);
+ BOOST_REQUIRE_EQUAL("app-backup", cat->name);
+ BOOST_REQUIRE(cat->summary);
+ BOOST_REQUIRE_EQUAL(169, cat->summary->length());
+}
+
BOOST_AUTO_TEST_CASE( getAllCategories )
{
auto cats = p->getAllCategories();
@@ -44,12 +54,43 @@ BOOST_AUTO_TEST_CASE( getCategoriesInSuper )
BOOST_REQUIRE_EQUAL(0, cats.size());
}
+BOOST_AUTO_TEST_CASE( getSyncs )
+{
+ auto syncs = p->getSyncs(3);
+ BOOST_REQUIRE_EQUAL(3, syncs.size());
+ BOOST_REQUIRE_EQUAL("2015-12-07T15:01:06.742996", syncs.front().timestamp);
+ BOOST_REQUIRE_EQUAL(3, syncs.front().ebuilds);
+ BOOST_REQUIRE_EQUAL("2015-11-29T15:00:49.856355", syncs.back().timestamp);
+ BOOST_REQUIRE_EQUAL(3, syncs.back().ebuilds);
+}
+
+BOOST_AUTO_TEST_CASE( getCategoriesWithRecentAdditions )
+{
+ auto cats = p->getCategoriesWithRecentAdditions(3);
+ BOOST_REQUIRE_EQUAL(4, cats.size());
+ BOOST_REQUIRE_EQUAL("dev-vcs", cats.front()->name);
+ BOOST_REQUIRE_EQUAL("app-backup", cats.back()->name);
+}
+
+BOOST_AUTO_TEST_CASE( getAllOverviewCategories )
+{
+ auto cats = p->getAllOverviewCategories();
+ BOOST_REQUIRE_EQUAL(3, cats.size());
+ BOOST_REQUIRE_EQUAL("app", cats.begin()->first);
+ BOOST_REQUIRE_EQUAL(2, cats["app"].size());
+ BOOST_REQUIRE_EQUAL("app-backup", cats["app"].front()->name);
+ BOOST_REQUIRE_EQUAL("app-crypt", cats["app"].back()->name);
+ BOOST_REQUIRE_EQUAL("2015-12-02T19:12:59.916989", cats["app"].back()->lastaddition);
+ BOOST_REQUIRE_EQUAL("net", cats.rbegin()->first);
+}
+
BOOST_AUTO_TEST_CASE( getOverviewCategoriesInSuper )
{
auto cats = p->getOverviewCategoriesInSuper("dev");
BOOST_REQUIRE_EQUAL(2, cats.size());
BOOST_REQUIRE_EQUAL("dev-ml", cats.front()->name);
BOOST_REQUIRE_EQUAL("dev-vcs", cats.back()->name);
+ BOOST_REQUIRE_EQUAL("2015-08-24T20:20:23.209651", cats.back()->lastaddition);
BOOST_REQUIRE_EQUAL(136, cats.front()->packagecount);
BOOST_REQUIRE_EQUAL(88, cats.back()->packagecount);
cats = p->getOverviewCategoriesInSuper("net");
@@ -90,6 +131,14 @@ BOOST_AUTO_TEST_CASE( findPackageMissing )
BOOST_REQUIRE_EQUAL(53258, (*pkg)->packageid);
}
+BOOST_AUTO_TEST_CASE( getAllPackages )
+{
+ auto pkgs = p->getAllPackages();
+ BOOST_REQUIRE_EQUAL(444, pkgs.size());
+ BOOST_REQUIRE_EQUAL("archway", pkgs.front()->name);
+ BOOST_REQUIRE_EQUAL("vzdump", pkgs.back()->name);
+}
+
BOOST_AUTO_TEST_CASE( getPackagesInCategory )
{
auto pkgs = p->getPackagesInCategory(311);
@@ -98,6 +147,22 @@ BOOST_AUTO_TEST_CASE( getPackagesInCategory )
BOOST_REQUIRE_EQUAL("veracity", pkgs.back()->name);
}
+BOOST_AUTO_TEST_CASE( getPackagesWithRecentAdditions )
+{
+ auto pkgs = p->getPackagesWithRecentAdditions(3);
+ BOOST_REQUIRE_EQUAL(8, pkgs.size());
+ BOOST_REQUIRE_EQUAL("mercurial", pkgs.front()->name);
+ BOOST_REQUIRE_EQUAL("letsencrypt", pkgs.back()->name);
+}
+
+BOOST_AUTO_TEST_CASE( getPackagesPopular )
+{
+ auto pkgs = p->getTopTrackedPackages(3);
+ BOOST_REQUIRE_EQUAL(3, pkgs.size());
+ BOOST_REQUIRE_EQUAL("squid", pkgs.front()->name);
+ BOOST_REQUIRE_EQUAL("subversion", pkgs.back()->name);
+}
+
BOOST_AUTO_TEST_CASE( searchEmpty )
{
auto matches = p->getPackagesSearch("");