From 9c74c8ab4a4b1f507688ff39480fd66e9a07b77b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 24 Apr 2016 18:26:48 +0100 Subject: Tidy up file difference merge with newer features --- gentoobrowse-api/service/maintenanceimpl.cpp | 10 ++++------ .../service/sql/maintenance/createTempFileListView.sql | 11 ----------- gentoobrowse-api/service/sql/maintenance/fileList.sql | 13 +++++++++++++ 3 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 gentoobrowse-api/service/sql/maintenance/createTempFileListView.sql create mode 100644 gentoobrowse-api/service/sql/maintenance/fileList.sql diff --git a/gentoobrowse-api/service/maintenanceimpl.cpp b/gentoobrowse-api/service/maintenanceimpl.cpp index d6b13a2..aec1cba 100644 --- a/gentoobrowse-api/service/maintenanceimpl.cpp +++ b/gentoobrowse-api/service/maintenanceimpl.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "maintenance/categoryMetaProcessor.h" #include "maintenance/packageManifestProcessor.h" #include "maintenance/packageMetaProcessor.h" @@ -118,26 +118,24 @@ namespace Gentoo { i->execute(); } } - dbc->execute(sql::maintenance::createTempFileListView::sql); } void Maintenance::processChanges(DB::Connection * dbc, const boost::filesystem::path & tmp) { + DB::StaticSqlWriter src(sql::maintenance::fileList::sql); DB::TablePatch tp; - tp.src = "tmp"; + tp.srcExpr = &src; tp.dest = "gentoobrowse.files"; tp.pk = {"repoid", "filename"}; tp.cols = {"repoid", "filename", "filetypeid", "pathparts", "filesize", "moddate"}; tp.beforeDelete = boost::bind(&Maintenance::fileDeleted, this, dbc, tmp, _1); tp.beforeUpdate = boost::bind(&Maintenance::fileChanged, this, dbc, tmp, _1); tp.beforeInsert = boost::bind(&Maintenance::fileCreated, this, dbc, tmp, _1); - DB::StaticSqlWriter obpo( - "(SELECT processOrder FROM gentoobrowse.filetypes ft WHERE ft.filetypeid = b.filetypeid) NULLS LAST"); + DB::StaticSqlWriter obpo("processOrder NULLS LAST"); tp.order = &obpo; dbc->patchTable(&tp); boost::filesystem::remove_all(tmp); - dbc->execute("DROP VIEW tmp"); dbc->execute("DROP TABLE filelist"); } diff --git a/gentoobrowse-api/service/sql/maintenance/createTempFileListView.sql b/gentoobrowse-api/service/sql/maintenance/createTempFileListView.sql deleted file mode 100644 index f40473e..0000000 --- a/gentoobrowse-api/service/sql/maintenance/createTempFileListView.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TEMPORARY VIEW tmp AS -SELECT - r.repoid, - fl.filename, - ft.filetypeid, - (STRING_TO_ARRAY(fl.filename, '/'))[2:100] pathparts, - fl.filesize, - fl.filemtime moddate -FROM filelist fl, gentoobrowse.repos r, gentoobrowse.filetypes ft -WHERE (STRING_TO_ARRAY(fl.filename, '/'))[1] = r.name -AND (STRING_TO_ARRAY(fl.filename, '/'))[2:100] ~ ft.spec diff --git a/gentoobrowse-api/service/sql/maintenance/fileList.sql b/gentoobrowse-api/service/sql/maintenance/fileList.sql new file mode 100644 index 0000000..dd1c9da --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/fileList.sql @@ -0,0 +1,13 @@ +( +SELECT + r.repoid, + fl.filename, + ft.filetypeid, + ft.processOrder, + (STRING_TO_ARRAY(fl.filename, '/'))[2:100] pathparts, + fl.filesize, + fl.filemtime moddate +FROM filelist fl, gentoobrowse.repos r, gentoobrowse.filetypes ft +WHERE (STRING_TO_ARRAY(fl.filename, '/'))[1] = r.name +AND (STRING_TO_ARRAY(fl.filename, '/'))[2:100] ~ ft.spec +) -- cgit v1.2.3