summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-04-20 00:08:29 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-04-25 21:25:33 +0100
commit514157e2b51fd126112a1be5febb57576a23dec1 (patch)
tree474bb1d6336d4899d6bd55a6b477319dcc90d2c0
parentNo more messy piping off a find process (diff)
downloadgentoobrowse-api-514157e2b51fd126112a1be5febb57576a23dec1.tar.bz2
gentoobrowse-api-514157e2b51fd126112a1be5febb57576a23dec1.tar.xz
gentoobrowse-api-514157e2b51fd126112a1be5febb57576a23dec1.zip
Process file changes according to predefined config
-rw-r--r--gentoobrowse-api/db/schema.sql3
-rw-r--r--gentoobrowse-api/service/maintenanceimpl.cpp25
-rw-r--r--gentoobrowse-api/unittests/basedata.sql2
-rw-r--r--gentoobrowse-api/unittests/data.sql2
-rw-r--r--gentoobrowse-api/unittests/fixtures/filetypes.dat22
5 files changed, 40 insertions, 14 deletions
diff --git a/gentoobrowse-api/db/schema.sql b/gentoobrowse-api/db/schema.sql
index fd45411..4222c8e 100644
--- a/gentoobrowse-api/db/schema.sql
+++ b/gentoobrowse-api/db/schema.sql
@@ -354,7 +354,8 @@ ALTER FUNCTION gentoobrowse.filecontent(f files) OWNER TO gentoo;
CREATE TABLE filetypes (
filetypeid integer NOT NULL,
description text NOT NULL,
- spec filterspec[] NOT NULL
+ spec filterspec[] NOT NULL,
+ processOrder integer
);
ALTER TABLE filetypes OWNER TO gentoo;
-- Name: TABLE filetypes; Type: COMMENT; Schema: gentoobrowse; Owner: gentoo
diff --git a/gentoobrowse-api/service/maintenanceimpl.cpp b/gentoobrowse-api/service/maintenanceimpl.cpp
index 3e8f8f9..f0247c7 100644
--- a/gentoobrowse-api/service/maintenanceimpl.cpp
+++ b/gentoobrowse-api/service/maintenanceimpl.cpp
@@ -1,11 +1,26 @@
#include "maintenanceimpl.h"
#include <selectcommandUtil.impl.h>
#include <tablepatch.h>
+#include <sqlWriter.h>
#include <buffer.h>
#include <boost/filesystem/operations.hpp>
#include <sql/maintenance/createTempFileListTable.sql.h>
#include <sql/maintenance/createTempFileListView.sql.h>
+/*
+1 package metadata {"(1,metadata)","(2,md5-cache)"}
+2 changelog {"(3,ChangeLog)"}
+3 masks {"(1,profiles)","(2,package.mask)"}
+4 package metadata.xml {"(3,metadata.xml)"}
+5 use_global {"(1,profiles)","(2,use.desc)"}
+6 use_local {"(1,profiles)","(2,use.local.desc)"}
+7 licenses {"(1,licenses)"}
+8 manifests {"(3,Manifest)"}
+9 use_grouped {"(1,profiles)","(2,desc)","(3,%.desc)"}
+10 category metadata {"(2,metadata.xml)"}
+11 news {"(1,metadata)","(2,news)","(4,%.txt)"}
+*/
+
namespace Gentoo {
namespace Service {
Maintenance::Maintenance(IceTray::DatabasePoolPtr d) :
@@ -65,6 +80,14 @@ namespace Gentoo {
dbc->execute(sql::maintenance::createTempFileListView::sql);
}
+ class OrderByProcessOrder : public DB::SqlWriter {
+ public:
+ void writeSql(AdHoc::Buffer & sql) override
+ {
+ sql.append("(SELECT processOrder FROM gentoobrowse.filetypes ft WHERE ft.filetypeid = b.filetypeid) NULLS LAST");
+ }
+ };
+
void
Maintenance::processChanges(DB::Connection * dbc, const boost::filesystem::path & tmp)
{
@@ -76,6 +99,8 @@ namespace Gentoo {
tp.beforeDelete = boost::bind(&fileDeleted, dbc, tmp, _1);
tp.beforeUpdate = boost::bind(&fileChanged, dbc, tmp, _1);
tp.beforeInsert = boost::bind(&fileCreated, dbc, tmp, _1);
+ OrderByProcessOrder obpo;
+ tp.order = &obpo;
dbc->patchTable(&tp);
boost::filesystem::remove_all(tmp);
dbc->execute("DROP VIEW tmp");
diff --git a/gentoobrowse-api/unittests/basedata.sql b/gentoobrowse-api/unittests/basedata.sql
index e8e3d55..6a77ede 100644
--- a/gentoobrowse-api/unittests/basedata.sql
+++ b/gentoobrowse-api/unittests/basedata.sql
@@ -6,4 +6,4 @@ SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = gentoobrowse, pg_catalog;
-COPY gentoobrowse.filetypes (filetypeid, description, spec) FROM '$SCRIPTDIR/fixtures/filetypes.dat';
+COPY gentoobrowse.filetypes (filetypeid, description, spec, processOrder) FROM '$SCRIPTDIR/fixtures/filetypes.dat';
diff --git a/gentoobrowse-api/unittests/data.sql b/gentoobrowse-api/unittests/data.sql
index 069fd25..3299b02 100644
--- a/gentoobrowse-api/unittests/data.sql
+++ b/gentoobrowse-api/unittests/data.sql
@@ -17,7 +17,7 @@ COPY gentoobrowse.masksets (setno, person, email, dateadded, message, n) FROM '$
COPY gentoobrowse.ebuild_masks (setno, ebuildid) FROM '$SCRIPTDIR/fixtures/ebuild_masks.dat';
COPY gentoobrowse.ebuild_rdeps (ebuildid, packageid, versionspec, flags, op, slot) FROM '$SCRIPTDIR/fixtures/ebuild_rdeps.dat';
COPY gentoobrowse.ebuild_uses (ebuildid, use) FROM '$SCRIPTDIR/fixtures/ebuild_uses.dat';
-COPY gentoobrowse.filetypes (filetypeid, description, spec) FROM '$SCRIPTDIR/fixtures/filetypes.dat';
+COPY gentoobrowse.filetypes (filetypeid, description, spec, processOrder) FROM '$SCRIPTDIR/fixtures/filetypes.dat';
COPY gentoobrowse.files (filename, fileid, moddate, firstseen, cachedat, filetypeid, repoid, filesize, pathparts, encoding) FROM '$SCRIPTDIR/fixtures/files.dat';
COPY gentoobrowse.license (name, legalbumph) FROM '$SCRIPTDIR/fixtures/license.dat';
COPY gentoobrowse.news (newsid, title, posted, authorname, authoremail, atomspec, body, urls) FROM '$SCRIPTDIR/fixtures/news.dat';
diff --git a/gentoobrowse-api/unittests/fixtures/filetypes.dat b/gentoobrowse-api/unittests/fixtures/filetypes.dat
index 21f23fa..7f3d1dd 100644
--- a/gentoobrowse-api/unittests/fixtures/filetypes.dat
+++ b/gentoobrowse-api/unittests/fixtures/filetypes.dat
@@ -1,11 +1,11 @@
-2 changelog {"(3,ChangeLog)"}
-3 masks {"(1,profiles)","(2,package.mask)"}
-7 licenses {"(1,licenses)"}
-8 manifests {"(3,Manifest)"}
-9 use_grouped {"(1,profiles)","(2,desc)","(3,%.desc)"}
-5 use_global {"(1,profiles)","(2,use.desc)"}
-6 use_local {"(1,profiles)","(2,use.local.desc)"}
-1 package metadata {"(1,metadata)","(2,md5-cache)"}
-10 category metadata {"(2,metadata.xml)"}
-4 package metadata.xml {"(3,metadata.xml)"}
-11 news {"(1,metadata)","(2,news)","(4,%.txt)"}
+2 changelog {"(3,ChangeLog)"} \N
+3 masks {"(1,profiles)","(2,package.mask)"} \N
+7 licenses {"(1,licenses)"} \N
+8 manifests {"(3,Manifest)"} 2
+9 use_grouped {"(1,profiles)","(2,desc)","(3,%.desc)"} \N
+5 use_global {"(1,profiles)","(2,use.desc)"} \N
+6 use_local {"(1,profiles)","(2,use.local.desc)"} \N
+1 ebuild metadata {"(1,metadata)","(2,md5-cache)"} 3
+10 category metadata {"(2,metadata.xml)"} 1
+4 package metadata.xml {"(3,metadata.xml)"} \N
+11 news {"(1,metadata)","(2,news)","(4,%.txt)"} \N