diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-08 19:52:26 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-08 20:48:35 +0000 |
commit | 0fdc629cc18aa339e0a91e4fcd8fbb18f7f893be (patch) | |
tree | 7a2c5adf5e8266757f64524cb59a962a0c2a55fe | |
parent | Implement sending emails of news ebuilds and signup verification (diff) | |
download | gentoobrowse-api-0fdc629cc18aa339e0a91e4fcd8fbb18f7f893be.tar.bz2 gentoobrowse-api-0fdc629cc18aa339e0a91e4fcd8fbb18f7f893be.tar.xz gentoobrowse-api-0fdc629cc18aa339e0a91e4fcd8fbb18f7f893be.zip |
Updates to work with new icetray/libdbpp interfacesgentoobrowse-api-0.7
25 files changed, 47 insertions, 30 deletions
diff --git a/gentoobrowse-api/service/Jamfile.jam b/gentoobrowse-api/service/Jamfile.jam index 7300b68..d1b4833 100644 --- a/gentoobrowse-api/service/Jamfile.jam +++ b/gentoobrowse-api/service/Jamfile.jam @@ -26,6 +26,8 @@ lib gentoobrowse-service : <library>../..//glibmm <library>../..//libxmlpp <icetray.sql.namespace>Gentoo::Service + <icetray.sql.connector>postgresql + <icetray.sql.basedir>. <include>. : : <include>. diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp index 7a63932..ad3fb0b 100644 --- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp @@ -23,7 +23,7 @@ namespace Gentoo { void CategoryMetaProcessor::modified(DB::Connection * dbc, int64_t, const StringList & fn, const boost::filesystem::path & path) { - DB::ModifyCommandPtr m = dbc->modify(sql::maintenance::categoryMetaUpdate.getSql()); + auto m = sql::maintenance::categoryMetaUpdate.modify(dbc); U::XmlDoc md(path); m->bindParamS(0, md.getXPathValue("/catmetadata/longdescription[@lang='en']/text()") / @@ -35,7 +35,7 @@ namespace Gentoo { void CategoryMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn) { - auto m = dbc->modify(sql::maintenance::categoryMetaUpdate.getSql()); + auto m = sql::maintenance::categoryMetaUpdate.modify(dbc); m->bindNull(0); m->bindParamS(1, fn.front()); m->execute(); diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp index c19fda0..579ca0d 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp @@ -53,19 +53,19 @@ namespace Gentoo { const std::string ebuildVersion = matches.fetch(2); // Maybe create a category - auto ci = dbc->modify(sql::maintenance::categoryInsert.getSql()); + auto ci = sql::maintenance::categoryInsert.modify(dbc); ci->bindParamS(0, categoryName); ci->bindParamS(1, categoryName); ci->execute(); // Maybe create a package - auto pi = dbc->modify(sql::maintenance::packageInsert.getSql()); + auto pi = sql::maintenance::packageInsert.modify(dbc); pi->bindParamS(0, packageName); pi->bindParamS(1, ecp.get("DESCRIPTION")); pi->bindParamS(2, packageName); pi->bindParamS(3, categoryName); pi->execute(); // Create an ebuild - auto m = dbc->select(sql::maintenance::ebuildInsert.getSql()); + auto m = sql::maintenance::ebuildInsert.select(dbc); m->bindParamS(0, ebuildVersion); m->bindParamS(1, ebuildVersion); m->bindParamS(2, ecp.get("SLOT")); @@ -86,7 +86,7 @@ namespace Gentoo { Glib::MatchInfo matches; const Glib::ustring pv = fn[3]; if (packageVersion->match(pv, matches)) { - auto m = dbc->select(sql::maintenance::ebuildUpdate.getSql()); + auto m = sql::maintenance::ebuildUpdate.select(dbc); U::EbuildCacheParser ecp(path); m->bindParamS(0, ecp.get("SLOT")); m->bindParamS(1, ecp.get("LICENSE")); @@ -118,12 +118,12 @@ namespace Gentoo { { "ebuildId", "int" }, { "use", "text" }, }); - useInsert = dbc->modify(sql::maintenance::ebuildUsesInsert.getSql()); + useInsert = sql::maintenance::ebuildUsesInsert.modify(dbc); Utils::Database::namedTemp(dbc, "tmpEbuildArchs", { { "ebuildId", "int" }, { "arch", "text" }, }); - archInsert = dbc->modify(sql::maintenance::ebuildArchsInsert.getSql()); + archInsert = sql::maintenance::ebuildArchsInsert.modify(dbc); } void @@ -172,13 +172,13 @@ namespace Gentoo { bool any = false; for(const auto & categoryName : catsDeleteFrom) { // Prune packages - auto pp = dbc->modify(sql::maintenance::packagePrune.getSql()); + auto pp = sql::maintenance::packagePrune.modify(dbc); pp->bindParamS(0, categoryName); any |= pp->execute(); } if (any) { // Prune categories - dbc->modify(sql::maintenance::categoryPrune.getSql())->execute(); + sql::maintenance::categoryPrune.modify(dbc)->execute(); } } } @@ -229,7 +229,7 @@ namespace Gentoo { t.where = &pwf; dbc->patchTable(&t); // Description - auto u = dbc->modify(sql::maintenance::packageDescUpdate.getSql()); + auto u = sql::maintenance::packageDescUpdate.modify(dbc); u->bindParamS(0, ecp.get("DESCRIPTION")); u->bindParamI(1, packageId); u->execute(); @@ -267,7 +267,7 @@ namespace Gentoo { const std::string ebuildVersion = matches.fetch(2); // Delete ebuild - auto m = dbc->modify(sql::maintenance::ebuildDelete.getSql()); + auto m = sql::maintenance::ebuildDelete.modify(dbc); m->bindParamI(0, repoId); m->bindParamS(1, categoryName); m->bindParamS(2, packageName); diff --git a/gentoobrowse-api/service/maintenance/newsProcessor.cpp b/gentoobrowse-api/service/maintenance/newsProcessor.cpp index a4387d4..07230ba 100644 --- a/gentoobrowse-api/service/maintenance/newsProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/newsProcessor.cpp @@ -36,7 +36,7 @@ namespace Gentoo { void NewsProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn) { - auto del = dbc->modify(sql::maintenance::newsDelete.getSql()); + auto del = sql::maintenance::newsDelete.modify(dbc); del->bindParamS(0, *++fn.rbegin()); del->execute(); } diff --git a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp index 5d452f5..653db7f 100644 --- a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp @@ -23,7 +23,7 @@ namespace Gentoo { void PackageMetaProcessor::modified(DB::Connection * dbc, int64_t, const StringList & fn, const boost::filesystem::path & path) { - auto m = dbc->modify(sql::maintenance::packageMetaUpdate.getSql()); + auto m = sql::maintenance::packageMetaUpdate.modify(dbc); U::XmlDoc md(path); m->bindParamS(0, md.getXPathValue("/pkgmetadata/longdescription[@lang='en']/text()") / @@ -37,7 +37,7 @@ namespace Gentoo { void PackageMetaProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn) { - auto m = dbc->modify(sql::maintenance::packageMetaUpdate.getSql()); + auto m = sql::maintenance::packageMetaUpdate.modify(dbc); m->bindNull(0); m->bindNull(1); m->bindParamS(2, fn[0]); diff --git a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp index 5fd998f..78d8897 100644 --- a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp @@ -25,11 +25,11 @@ namespace Gentoo { class UpdatesPatch : public DB::TablePatch, public DB::SqlWriter { public: UpdatesPatch(DB::Connection * db) : - movePackageDirFiles(db->modify(sql::maintenance::updatesPackageDirFiles.getSql())), - moveMD5CacheFiles(db->modify(sql::maintenance::updatesMD5CacheFiles.getSql())), - findPackage(db->select(sql::portage::findPackage.getSql())), - movePackages(db->modify(sql::maintenance::updatesMovePackages.getSql())), - moveUserPackages(db->modify(sql::maintenance::updatesMoveUserPackages.getSql())), + movePackageDirFiles(sql::maintenance::updatesPackageDirFiles.modify(db)), + moveMD5CacheFiles(sql::maintenance::updatesMD5CacheFiles.modify(db)), + findPackage(sql::portage::findPackage.select(db)), + movePackages(sql::maintenance::updatesMovePackages.modify(db)), + moveUserPackages(sql::maintenance::updatesMoveUserPackages.modify(db)), updatePacks("updatePack") { this->src = Utils::Database::emptyClone(db, "gentoobrowse.updates"); diff --git a/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp b/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp index 9f9705e..b21a701 100644 --- a/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/useGroupProcessor.cpp @@ -21,7 +21,7 @@ namespace Gentoo { void UseGroupProcessor::created(DB::Connection * dbc, int64_t, const StringList &, const boost::filesystem::path & path) { - auto m = dbc->select(sql::maintenance::useGroupsInsert.getSql()); + auto m = sql::maintenance::useGroupsInsert.select(dbc); m->bindParamS(0, path.stem().string()); m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) { this->mergeContent(dbc, path, useGroupId); @@ -31,7 +31,7 @@ namespace Gentoo { void UseGroupProcessor::modified(DB::Connection * dbc, int64_t, const StringList &, const boost::filesystem::path & path) { - auto m = dbc->select(sql::maintenance::useGroupsGetId.getSql()); + auto m = sql::maintenance::useGroupsGetId.select(dbc); m->bindParamS(0, path.stem().string()); m->forEachRow<int64_t>([this, dbc, &path](auto useGroupId) { this->mergeContent(dbc, path, useGroupId); @@ -72,7 +72,7 @@ namespace Gentoo { void UseGroupProcessor::deleted(DB::Connection * dbc, int64_t, const StringList & fn) { - auto m = dbc->modify(sql::maintenance::useGroupsDelete.getSql()); + auto m = sql::maintenance::useGroupsDelete.modify(dbc); m->bindParamS(0, fn.back().substr(0, fn.back().find('.'))); m->execute(); } diff --git a/gentoobrowse-api/service/maintenanceChangeLogs.cpp b/gentoobrowse-api/service/maintenanceChangeLogs.cpp index d0e359a..7c1ef81 100644 --- a/gentoobrowse-api/service/maintenanceChangeLogs.cpp +++ b/gentoobrowse-api/service/maintenanceChangeLogs.cpp @@ -59,12 +59,12 @@ namespace Gentoo { auto dbc = db->get(); DB::TransactionScope tx(dbc.get()); - auto cli = dbc->modify(sql::maintenance::changeLogInsert.getSql()); + auto cli = sql::maintenance::changeLogInsert.modify(dbc.get()); - dbc->select(sql::maintenance::changeLogRoots.getSql())->forEachRow<int64_t, std::string, std::string>([&cli,&c,&dbc](auto repoId, const auto & repoName, const auto & repoRoot) { + sql::maintenance::changeLogRoots.select(dbc.get())->forEachRow<int64_t, std::string, std::string>([&cli,&c,&dbc](auto repoId, const auto & repoName, const auto & repoRoot) { std::set<std::string> processedChanges; { - auto changes = dbc->select(sql::maintenance::changeLogRepoCommits.getSql()); + auto changes = sql::maintenance::changeLogRepoCommits.select(dbc.get()); changes->bindParamI(0, repoId); changes->forEachRow<std::string>([&processedChanges](const auto & c) { processedChanges.insert(c); }); } diff --git a/gentoobrowse-api/service/sql/maintenance/changeLogRoots.sql b/gentoobrowse-api/service/sql/maintenance/changeLogRoots.sql index ac05611..622e82f 100644 --- a/gentoobrowse-api/service/sql/maintenance/changeLogRoots.sql +++ b/gentoobrowse-api/service/sql/maintenance/changeLogRoots.sql @@ -1,2 +1,3 @@ +-- libdbpp:no-cursor SELECT r.repoid, r.name, r.path FROM gentoobrowse.repos r diff --git a/gentoobrowse-api/service/sql/portage/findCategory.sql b/gentoobrowse-api/service/sql/portage/findCategory.sql index b1cb130..49e2f62 100644 --- a/gentoobrowse-api/service/sql/portage/findCategory.sql +++ b/gentoobrowse-api/service/sql/portage/findCategory.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT c.categoryid, c.name, c.summary FROM gentoobrowse.categories c WHERE c.name = ? diff --git a/gentoobrowse-api/service/sql/portage/findPackage.sql b/gentoobrowse-api/service/sql/portage/findPackage.sql index 7e45894..316c2b2 100644 --- a/gentoobrowse-api/service/sql/portage/findPackage.sql +++ b/gentoobrowse-api/service/sql/portage/findPackage.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd FROM gentoobrowse.packages p, gentoobrowse.categories c WHERE c.categoryid = p.categoryid diff --git a/gentoobrowse-api/service/sql/portage/getBug.sql b/gentoobrowse-api/service/sql/portage/getBug.sql index 36d4586..87448f9 100644 --- a/gentoobrowse-api/service/sql/portage/getBug.sql +++ b/gentoobrowse-api/service/sql/portage/getBug.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT b.bugid, b.severity, b.status, b.summary, b.firstseen FROM gentoobrowse.bugs b WHERE b.bugid = ? diff --git a/gentoobrowse-api/service/sql/portage/getCategory.sql b/gentoobrowse-api/service/sql/portage/getCategory.sql index 27ee14d..254edfa 100644 --- a/gentoobrowse-api/service/sql/portage/getCategory.sql +++ b/gentoobrowse-api/service/sql/portage/getCategory.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT c.categoryid, c.name, c.summary FROM gentoobrowse.categories c WHERE c.categoryid = ? diff --git a/gentoobrowse-api/service/sql/portage/getNewsItem.sql b/gentoobrowse-api/service/sql/portage/getNewsItem.sql index d69aa6a..be5d716 100644 --- a/gentoobrowse-api/service/sql/portage/getNewsItem.sql +++ b/gentoobrowse-api/service/sql/portage/getNewsItem.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor 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/service/sql/portage/getPackage.sql b/gentoobrowse-api/service/sql/portage/getPackage.sql index 001bf88..7ae0a9a 100644 --- a/gentoobrowse-api/service/sql/portage/getPackage.sql +++ b/gentoobrowse-api/service/sql/portage/getPackage.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd FROM gentoobrowse.packages p WHERE p.packageid = ? diff --git a/gentoobrowse-api/service/sql/portage/getRepositories.sql b/gentoobrowse-api/service/sql/portage/getRepositories.sql index 3236628..f483fea 100644 --- a/gentoobrowse-api/service/sql/portage/getRepositories.sql +++ b/gentoobrowse-api/service/sql/portage/getRepositories.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor 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 index fc12ff8..36eea22 100644 --- a/gentoobrowse-api/service/sql/portage/getRepository.sql +++ b/gentoobrowse-api/service/sql/portage/getRepository.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT repoid, name, path FROM gentoobrowse.repos WHERE repoid = ? diff --git a/gentoobrowse-api/service/sql/portage/getSyncs.sql b/gentoobrowse-api/service/sql/portage/getSyncs.sql index eef5e3e..dea88ac 100644 --- a/gentoobrowse-api/service/sql/portage/getSyncs.sql +++ b/gentoobrowse-api/service/sql/portage/getSyncs.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT s.firstseen AS timestamp, COUNT(*) AS ebuilds FROM gentoobrowse.ebuilds s GROUP BY s.firstseen diff --git a/gentoobrowse-api/service/sql/portage/getUse.sql b/gentoobrowse-api/service/sql/portage/getUse.sql index ceaccf2..79e9ba1 100644 --- a/gentoobrowse-api/service/sql/portage/getUse.sql +++ b/gentoobrowse-api/service/sql/portage/getUse.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT use, description FROM gentoobrowse.use_global WHERE use = ? diff --git a/gentoobrowse-api/service/sql/portage/getUseUsage.sql b/gentoobrowse-api/service/sql/portage/getUseUsage.sql index afd3081..415874b 100644 --- a/gentoobrowse-api/service/sql/portage/getUseUsage.sql +++ b/gentoobrowse-api/service/sql/portage/getUseUsage.sql @@ -10,4 +10,4 @@ SELECT use, description, null, null, name FROM gentoobrowse.use_groups ugs, gentoobrowse.use_group ug WHERE ugs.usegroupid = ug.usegroupid AND ugs.name like SPLIT_PART(?, '_', 1) || '%' -AND ugs.name || '_' || ug.use = ?
\ No newline at end of file +AND ugs.name || '_' || ug.use = ? diff --git a/gentoobrowse-api/service/sql/users/authenticate.sql b/gentoobrowse-api/service/sql/users/authenticate.sql index 0b3ac09..0efdd38 100644 --- a/gentoobrowse-api/service/sql/users/authenticate.sql +++ b/gentoobrowse-api/service/sql/users/authenticate.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT userid, username, userrealname, useremail, signedup, lastmailshot FROM gentoobrowse.users WHERE username = ? diff --git a/gentoobrowse-api/service/sql/users/find.sql b/gentoobrowse-api/service/sql/users/find.sql index d7d5767..7db428c 100644 --- a/gentoobrowse-api/service/sql/users/find.sql +++ b/gentoobrowse-api/service/sql/users/find.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT userid, username, userrealname, useremail, signedup, lastmailshot FROM gentoobrowse.users WHERE username = ? diff --git a/gentoobrowse-api/service/sql/users/get.sql b/gentoobrowse-api/service/sql/users/get.sql index 49e8144..c6a66a1 100644 --- a/gentoobrowse-api/service/sql/users/get.sql +++ b/gentoobrowse-api/service/sql/users/get.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT userid, username, userrealname, useremail, signedup, lastmailshot FROM gentoobrowse.users WHERE userid = ? diff --git a/gentoobrowse-api/service/sql/users/tracked.sql b/gentoobrowse-api/service/sql/users/tracked.sql index 7bf2a8d..7133520 100644 --- a/gentoobrowse-api/service/sql/users/tracked.sql +++ b/gentoobrowse-api/service/sql/users/tracked.sql @@ -1,3 +1,4 @@ +-- libdbpp:no-cursor SELECT packageid FROM gentoobrowse.user_packages WHERE userid = ? diff --git a/gentoobrowse-api/service/usersimpl.cpp b/gentoobrowse-api/service/usersimpl.cpp index 60d0b64..f5fb111 100644 --- a/gentoobrowse-api/service/usersimpl.cpp +++ b/gentoobrowse-api/service/usersimpl.cpp @@ -75,7 +75,7 @@ void Users::remove(Ice::Int id, const std::string & password, const Ice::Current &) { auto dbc = db->get(); - auto del = dbc->modify(sql::users::safeDelete.getSql()); + auto del = sql::users::safeDelete.modify(dbc.get()); del->bindParamI(0, id); del->bindParamS(1, password); del->execute(); @@ -85,7 +85,7 @@ void Users::track(Ice::Int userId, Ice::Int packageId, const Ice::Current &) { auto dbc = db->get(); - auto track = dbc->modify(sql::users::track.getSql()); + auto track = sql::users::track.modify(dbc.get()); track->bindParamI(0, userId); track->bindParamI(1, packageId); track->execute(); @@ -95,7 +95,7 @@ void Users::untrack(Ice::Int userId, Ice::Int packageId, const Ice::Current &) { auto dbc = db->get(); - auto untrack = dbc->modify(sql::users::untrack.getSql()); + auto untrack = sql::users::untrack.modify(dbc.get()); untrack->bindParamI(0, userId); untrack->bindParamI(1, packageId); untrack->execute(); |