diff options
7 files changed, 21 insertions, 46 deletions
diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp index bf75b16..6cb8b64 100644 --- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp @@ -1,11 +1,13 @@ #include "categoryMetaProcessor.h" #include <modifycommand.h> #include <fileUtils.h> +#include <optionalUtils.h> #include "utils/xmlUtils.h" #include "utils/dbUtils.h" #include <sql/maintenance/categoryMetaUpdate.sql.h> namespace U = Gentoo::Utils; +using namespace AdHoc; using namespace AdHoc::FileUtils; namespace Gentoo { @@ -23,10 +25,9 @@ namespace Gentoo { { DB::ModifyCommandPtr m = dbc->modify(sql::maintenance::categoryMetaUpdate.getSql()); U::XmlDoc md(path); - U::Database::bindOptionalsS(m.get(), 0, { - md.getXPathValue("/catmetadata/longdescription[@lang='en']/text()"), - md.getXPathValue("/catmetadata/longdescription[1]/text()") - }); + m->bindParamS(0, + md.getXPathValue("/catmetadata/longdescription[@lang='en']/text()") / + md.getXPathValue("/catmetadata/longdescription[1]/text()")); m->bindParamS(1, (fn / 1).string()); m->execute(); } diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp index cbc74bd..64e0cef 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp @@ -7,6 +7,7 @@ #include <boost/algorithm/string/join.hpp> #include <glibmm/regex.h> #include <tablepatch.h> +#include <optionalUtils.h> #include "depend.h" #include "utils/dbUtils.h" #include "utils/ebuildCacheParser.h" @@ -25,6 +26,7 @@ #include <sql/maintenance/ebuildArchsInsert.sql.h> namespace U = Gentoo::Utils; +using namespace AdHoc; using namespace AdHoc::FileUtils; static Glib::RefPtr<Glib::Regex> packageVersion = Glib::Regex::create("^(.+)-([0-9].*)$"); @@ -59,7 +61,7 @@ namespace Gentoo { // Maybe create a package auto pi = dbc->modify(sql::maintenance::packageInsert.getSql()); pi->bindParamS(0, packageName); - Utils::Database::bindOptionalsS(pi.get(), 1, { ecp.get("DESCRIPTION") }); + pi->bindParamS(1, ecp.get("DESCRIPTION")); pi->bindParamS(2, packageName); pi->bindParamS(3, categoryName); pi->execute(); @@ -67,8 +69,8 @@ namespace Gentoo { auto m = dbc->select(sql::maintenance::ebuildInsert.getSql()); m->bindParamS(0, ebuildVersion); m->bindParamS(1, ebuildVersion); - Utils::Database::bindOptionalsS(m.get(), 2, { ecp.get("SLOT") }); - Utils::Database::bindOptionalsS(m.get(), 3, { ecp.get("LICENSE") }); + m->bindParamS(2, ecp.get("SLOT")); + m->bindParamS(3, ecp.get("LICENSE")); m->bindParamT(4, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec)); m->bindParamS(5, repoName); m->bindParamS(6, categoryName); @@ -88,8 +90,8 @@ namespace Gentoo { if (packageVersion->match(pv, matches)) { auto m = dbc->select(sql::maintenance::ebuildUpdate.getSql()); U::EbuildCacheParser ecp(path); - Utils::Database::bindOptionalsS(m.get(), 0, { ecp.get("SLOT") }); - Utils::Database::bindOptionalsS(m.get(), 1, { ecp.get("LICENSE") }); + m->bindParamS(0, ecp.get("SLOT")); + m->bindParamS(1, ecp.get("LICENSE")); m->bindParamT(2, boost::posix_time::from_time_t(ecp.getStat().st_mtim.tv_sec)); m->bindParamS(3, (fn / 0).string()); // repo m->bindParamS(4, (fn / 3).string()); // category @@ -231,7 +233,7 @@ namespace Gentoo { dbc->patchTable(&t); // Description auto u = dbc->modify(sql::maintenance::packageDescUpdate.getSql()); - Utils::Database::bindOptionalsS(u.get(), 0, { ecp.get("DESCRIPTION") }); + u->bindParamS(0, ecp.get("DESCRIPTION")); u->bindParamI(1, packageId); u->execute(); } diff --git a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp index 837cc18..1e3f032 100644 --- a/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/packageMetaProcessor.cpp @@ -1,11 +1,13 @@ #include "packageMetaProcessor.h" #include <modifycommand.h> +#include <optionalUtils.h> #include <fileUtils.h> #include "utils/xmlUtils.h" #include "utils/dbUtils.h" #include <sql/maintenance/packageMetaUpdate.sql.h> namespace U = Gentoo::Utils; +using namespace AdHoc; using namespace AdHoc::FileUtils; namespace Gentoo { @@ -23,13 +25,10 @@ namespace Gentoo { { auto m = dbc->modify(sql::maintenance::packageMetaUpdate.getSql()); U::XmlDoc md(path); - U::Database::bindOptionalsS(m.get(), 0, { - md.getXPathValue("/pkgmetadata/longdescription[@lang='en']/text()"), - md.getXPathValue("/pkgmetadata/longdescription[1]/text()") - }); - U::Database::bindOptionalsS(m.get(), 1, { - md.getXPathValue("/pkgmetadata/herd/text()") - }); + m->bindParamS(0, + md.getXPathValue("/pkgmetadata/longdescription[@lang='en']/text()") / + md.getXPathValue("/pkgmetadata/longdescription[1]/text()")); + m->bindParamS(1, md.getXPathValue("/pkgmetadata/herd/text()")); m->bindParamS(2, (fn / 1).string()); m->bindParamS(3, (fn / 2).string()); m->execute(); diff --git a/gentoobrowse-api/service/maintenanceChangeLogs.cpp b/gentoobrowse-api/service/maintenanceChangeLogs.cpp index 4a6a278..d0e359a 100644 --- a/gentoobrowse-api/service/maintenanceChangeLogs.cpp +++ b/gentoobrowse-api/service/maintenanceChangeLogs.cpp @@ -122,7 +122,7 @@ namespace Gentoo { auto sig = git_commit_author(commit.get()); cli->bindParamT(2, boost::posix_time::from_time_t(sig->when.time)); cli->bindParamS(3, git_commit_summary(commit.get())); - Utils::Database::bindOptionalS(cli.get(), 4, git_commit_body(commit.get())); + cli->bindParamS(4, git_commit_body(commit.get())); cli->bindParamS(5, sig->name); cli->bindParamS(6, sig->email); cli->bindParamS(7, Slicer::packPqTextArray(fs)); diff --git a/gentoobrowse-api/service/utils/dbUtils.cpp b/gentoobrowse-api/service/utils/dbUtils.cpp index 1d915d5..3e70281 100644 --- a/gentoobrowse-api/service/utils/dbUtils.cpp +++ b/gentoobrowse-api/service/utils/dbUtils.cpp @@ -8,30 +8,6 @@ namespace Gentoo { namespace Utils { namespace Database { - bool - bindOptionalsS(DB::Command * db, unsigned int c, const std::vector<boost::optional<Glib::ustring> > & vs) - { - for(const auto & v : vs) { - if (v) { - db->bindParamS(c, *v); - return true; - } - } - db->bindNull(c); - return false; - } - - void - bindOptionalS(DB::Command * db, unsigned int c, const char * v) - { - if (v) { - db->bindParamS(c, v); - } - else { - db->bindNull(c); - } - } - std::string emptyClone(DB::Connection * db, const std::string & orig) { diff --git a/gentoobrowse-api/service/utils/dbUtils.h b/gentoobrowse-api/service/utils/dbUtils.h index 03d468e..cbb8292 100644 --- a/gentoobrowse-api/service/utils/dbUtils.h +++ b/gentoobrowse-api/service/utils/dbUtils.h @@ -10,9 +10,6 @@ namespace Gentoo { namespace Utils { namespace Database { - bool bindOptionalsS(DB::Command * db, unsigned int c, const std::vector<boost::optional<Glib::ustring> > & vs); - void bindOptionalS(DB::Command * db, unsigned int c, const char * v); - std::string emptyClone(DB::Connection *, const std::string &); std::pair<std::string, DB::ModifyCommandPtr> namedTemp(DB::Connection *, const std::string &, const std::map<std::string, const std::string> & cols); void drop(DB::Connection *, const std::string &); diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.cpp b/gentoobrowse-api/service/utils/splitEbuildProps.cpp index 8116742..97790b5 100644 --- a/gentoobrowse-api/service/utils/splitEbuildProps.cpp +++ b/gentoobrowse-api/service/utils/splitEbuildProps.cpp @@ -22,7 +22,7 @@ namespace Gentoo { SplitEbuildProps::bindParams(DB::Command * c, unsigned int & offset) { c->bindParamI(offset++, entityId); - Gentoo::Utils::Database::bindOptionalsS(c, offset++, { props }); + c->bindParamS(offset++, props); } } } |