summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/api/portage.ice3
-rw-r--r--gentoobrowse-api/domain/portage-models.ice9
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp14
-rw-r--r--gentoobrowse-api/service/portageimpl.h3
-rw-r--r--gentoobrowse-api/service/sql/portage/getRepositories.sql3
-rw-r--r--gentoobrowse-api/service/sql/portage/getRepository.sql3
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp25
7 files changed, 60 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index 98b39fe..1f211fd 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -36,6 +36,9 @@ module Gentoo {
idempotent NewsItem getNewsItem(string newsid) throws Slicer::NoRowsReturned;
idempotent News getNewsSearch(string query);
idempotent News getNewsRecent(int items);
+
+ idempotent Repository getRepository(int id) throws Slicer::NoRowsReturned;
+ idempotent Repositories getRepositories();
};
};
diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice
index 5ee9b76..dd57551 100644
--- a/gentoobrowse-api/domain/portage-models.ice
+++ b/gentoobrowse-api/domain/portage-models.ice
@@ -107,6 +107,13 @@ module Gentoo {
int ebuilds;
};
+ struct Repository {
+ ["slicer:db:pkey"]
+ int repoid;
+ string name;
+ string path;
+ };
+
[ "slicer:element:category" ]
sequence<Category> Categories;
[ "slicer:element:package" ]
@@ -123,6 +130,8 @@ module Gentoo {
sequence<Sync> Syncs;
[ "slicer:element:mask" ]
sequence<Mask> Masks;
+ [ "slicer:element:repo" ]
+ sequence<Repository> Repositories;
};
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index 689b173..a12c8d7 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -28,6 +28,8 @@
#include <sql/portage/getNewsItem.sql.h>
#include <sql/portage/getNewsSearch.sql.h>
#include <sql/portage/getNewsRecent.sql.h>
+#include <sql/portage/getRepository.sql.h>
+#include <sql/portage/getRepositories.sql.h>
namespace Gentoo {
namespace Service {
@@ -215,6 +217,18 @@ Portage::getNewsRecent(Ice::Int items, const Ice::Current &)
{
return fetchCache<Gentoo::News>(sql::portage::getNewsRecent, 30, items);
}
+
+Gentoo::Repository
+Portage::getRepository(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::Repository>(sql::portage::getRepository, 30, id);
+}
+
+Gentoo::Repositories
+Portage::getRepositories(const Ice::Current &)
+{
+ return fetchCache<Gentoo::Repositories>(sql::portage::getRepositories, 30);
+}
}
}
diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h
index 8810068..42d57e4 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -43,6 +43,9 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab
Gentoo::NewsItemPtr getNewsItem(const std::string &, const Ice::Current &) override;
Gentoo::News getNewsSearch(const std::string &, const Ice::Current &) override;
Gentoo::News getNewsRecent(Ice::Int, const Ice::Current &) override;
+
+ Gentoo::Repository getRepository(Ice::Int, const Ice::Current &) override;
+ Gentoo::Repositories getRepositories(const Ice::Current &) override;
};
}
}
diff --git a/gentoobrowse-api/service/sql/portage/getRepositories.sql b/gentoobrowse-api/service/sql/portage/getRepositories.sql
new file mode 100644
index 0000000..3236628
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getRepositories.sql
@@ -0,0 +1,3 @@
+SELECT repoid, name, path
+FROM gentoobrowse.repos
+ORDER BY repoid
diff --git a/gentoobrowse-api/service/sql/portage/getRepository.sql b/gentoobrowse-api/service/sql/portage/getRepository.sql
new file mode 100644
index 0000000..fc12ff8
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getRepository.sql
@@ -0,0 +1,3 @@
+SELECT repoid, name, path
+FROM gentoobrowse.repos
+WHERE repoid = ?
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index 135ae7f..c408a83 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -382,5 +382,30 @@ BOOST_AUTO_TEST_CASE( getNewsRecent )
BOOST_REQUIRE_EQUAL("2015-10-07", ns.back()->posted);
}
+BOOST_AUTO_TEST_CASE( getRepository )
+{
+ auto r = p->getRepository(17);
+ BOOST_REQUIRE_EQUAL(17, r.repoid);
+ BOOST_REQUIRE_EQUAL("gentoo", r.name);
+ BOOST_REQUIRE_EQUAL("/usr/portage", r.path);
+}
+
+BOOST_AUTO_TEST_CASE( getRepositoryMissing )
+{
+ BOOST_REQUIRE_THROW(p->getRepository(1), Slicer::NoRowsReturned);
+}
+
+BOOST_AUTO_TEST_CASE( getRepositories )
+{
+ auto rs = p->getRepositories();
+ BOOST_REQUIRE_EQUAL(2, rs.size());
+ BOOST_REQUIRE_EQUAL(17, rs.front().repoid);
+ BOOST_REQUIRE_EQUAL("gentoo", rs.front().name);
+ BOOST_REQUIRE_EQUAL("/usr/portage", rs.front().path);
+ BOOST_REQUIRE_EQUAL(18, rs.back().repoid);
+ BOOST_REQUIRE_EQUAL("RandomLAN", rs.back().name);
+ BOOST_REQUIRE_EQUAL("/home/randomdan/dev/portage", rs.back().path);
+}
+
BOOST_AUTO_TEST_SUITE_END();