diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-11-04 12:06:53 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-11-04 12:06:53 +0000 |
commit | bfcbd95f3268e4585ad1100e383e4820566630fb (patch) | |
tree | a68904121b5733cc25af36737cb4d4e405f8e9ca | |
parent | Add support for search for use flags (diff) | |
download | gentoobrowse-api-bfcbd95f3268e4585ad1100e383e4820566630fb.tar.bz2 gentoobrowse-api-bfcbd95f3268e4585ad1100e383e4820566630fb.tar.xz gentoobrowse-api-bfcbd95f3268e4585ad1100e383e4820566630fb.zip |
Add support for getting a user's tracked packages
-rw-r--r-- | gentoobrowse-api/api/users.ice | 3 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/users/tracked.sql | 4 | ||||
-rw-r--r-- | gentoobrowse-api/service/usersimpl.cpp | 7 | ||||
-rw-r--r-- | gentoobrowse-api/service/usersimpl.h | 1 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testUsers.cpp | 7 |
5 files changed, 22 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/users.ice b/gentoobrowse-api/api/users.ice index d0c37f7..16fa7e2 100644 --- a/gentoobrowse-api/api/users.ice +++ b/gentoobrowse-api/api/users.ice @@ -5,6 +5,8 @@ #include <sqlExceptions.ice> module Gentoo { + sequence<int> PackageIds; + interface Users { User authenticate(string username, string password) throws Slicer::NoRowsReturned; User verify(string username, string verifyguid) throws Slicer::NoRowsReturned; @@ -16,6 +18,7 @@ module Gentoo { void track(int userId, int packageId); void untrack(int userId, int packageId); + PackageIds tracked(int userId); }; }; diff --git a/gentoobrowse-api/service/sql/users/tracked.sql b/gentoobrowse-api/service/sql/users/tracked.sql new file mode 100644 index 0000000..7bf2a8d --- /dev/null +++ b/gentoobrowse-api/service/sql/users/tracked.sql @@ -0,0 +1,4 @@ +SELECT packageid +FROM gentoobrowse.user_packages +WHERE userid = ? +ORDER BY packageid diff --git a/gentoobrowse-api/service/usersimpl.cpp b/gentoobrowse-api/service/usersimpl.cpp index 6aee42d..67a1bd1 100644 --- a/gentoobrowse-api/service/usersimpl.cpp +++ b/gentoobrowse-api/service/usersimpl.cpp @@ -8,6 +8,7 @@ #include <sql/users/safeDelete.sql.h> #include <sql/users/track.sql.h> #include <sql/users/untrack.sql.h> +#include <sql/users/tracked.sql.h> namespace Gentoo { namespace Service { @@ -75,6 +76,12 @@ Users::untrack(Ice::Int userId, Ice::Int packageId, const Ice::Current &) untrack->bindParamI(1, packageId); untrack->execute(); } + +Gentoo::PackageIds +Users::tracked(Ice::Int userId, const Ice::Current &) +{ + return fetchCache<Gentoo::PackageIds>(sql::users::tracked, 10, userId); +} } } diff --git a/gentoobrowse-api/service/usersimpl.h b/gentoobrowse-api/service/usersimpl.h index f97e2ad..ae342a9 100644 --- a/gentoobrowse-api/service/usersimpl.h +++ b/gentoobrowse-api/service/usersimpl.h @@ -21,6 +21,7 @@ class DLL_PUBLIC Users : public Gentoo::Users, IceTray::AbstractCachingDatabaseC void track(Ice::Int, Ice::Int, const Ice::Current &) override; void untrack(Ice::Int, Ice::Int, const Ice::Current &) override; + Gentoo::PackageIds tracked(Ice::Int, const Ice::Current &) override; }; } } diff --git a/gentoobrowse-api/unittests/testUsers.cpp b/gentoobrowse-api/unittests/testUsers.cpp index e4c1ac4..a4567f3 100644 --- a/gentoobrowse-api/unittests/testUsers.cpp +++ b/gentoobrowse-api/unittests/testUsers.cpp @@ -95,6 +95,13 @@ BOOST_AUTO_TEST_CASE( track ) u->track(1, 44473); } +BOOST_AUTO_TEST_CASE( tracked ) +{ + auto ids = u->tracked(1); + BOOST_REQUIRE_EQUAL(4, ids.size()); + BOOST_REQUIRE_EQUAL(44473, ids.front()); +} + BOOST_AUTO_TEST_CASE( untrack ) { u->untrack(1, 44473); |