From 8b9936d5d6cb1974340743ca6a5ca3ff0dec3088 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 21 Apr 2016 00:01:09 +0100 Subject: Move category maint SQL to .sql files --- gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp | 9 ++++++--- gentoobrowse-api/service/sql/maintenance/categoryDelete.sql | 2 ++ gentoobrowse-api/service/sql/maintenance/categoryInsert.sql | 2 ++ gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 gentoobrowse-api/service/sql/maintenance/categoryDelete.sql create mode 100644 gentoobrowse-api/service/sql/maintenance/categoryInsert.sql create mode 100644 gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp index 01f27f1..93c08f0 100644 --- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp @@ -3,6 +3,9 @@ #include "fileUtils.h" #include "xmlUtils.h" #include "dbUtils.h" +#include +#include +#include namespace U = Gentoo::Utils; using namespace Gentoo::Utils::File; @@ -14,7 +17,7 @@ namespace Gentoo { void CategoryMetaProcessor::created(DB::Connection * dbc, const boost::filesystem::path & fn, const boost::filesystem::path & path) const { - upsert(dbc->modify("INSERT INTO gentoobrowse.categories(summary, name) VALUES(?, ?)"), fn, path); + upsert(dbc->modify(sql::maintenance::categoryInsert::sql), fn, path); } void @@ -32,13 +35,13 @@ namespace Gentoo { void CategoryMetaProcessor::modified(DB::Connection * dbc, const boost::filesystem::path & fn, const boost::filesystem::path & path) const { - upsert(dbc->modify("UPDATE gentoobrowse.categories SET summary = ? WHERE name = ?)"), fn, path); + upsert(dbc->modify(sql::maintenance::categoryUpdate::sql), fn, path); } void CategoryMetaProcessor::deleted(DB::Connection * dbc, const boost::filesystem::path & fn) const { - auto m = dbc->modify("DELETE FROM gentoobrowse.categories WHERE name = ?"); + auto m = dbc->modify(sql::maintenance::categoryDelete::sql); m->bindParamS(0, (fn / 1).string()); m->execute(); } diff --git a/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql b/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql new file mode 100644 index 0000000..ad961c8 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql @@ -0,0 +1,2 @@ +DELETE FROM gentoobrowse.categories +WHERE name = ? diff --git a/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql new file mode 100644 index 0000000..8c3f685 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql @@ -0,0 +1,2 @@ +INSERT INTO gentoobrowse.categories(summary, name) +VALUES(?, ?) diff --git a/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql new file mode 100644 index 0000000..1b0ef38 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql @@ -0,0 +1,3 @@ +UPDATE gentoobrowse.categories SET + summary = ? +WHERE name = ? -- cgit v1.2.3