From 8ffd5e8f82023e44a1514df3cf16727cc5ad03a9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 31 May 2016 20:57:26 +0100 Subject: Don't require processOrder on file types --- gentoobrowse-api/db/schema.sql | 3 +-- .../service/maintenancePackageTree.cpp | 6 +++++- .../service/sql/maintenance/fileListCreate.sql | 1 - gentoobrowse-api/unittests/basedata.sql | 2 +- gentoobrowse-api/unittests/data.sql | 2 +- gentoobrowse-api/unittests/fixtures/filetypes.dat | 22 +++++++++++----------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gentoobrowse-api/db/schema.sql b/gentoobrowse-api/db/schema.sql index afd47af..ec56da2 100644 --- a/gentoobrowse-api/db/schema.sql +++ b/gentoobrowse-api/db/schema.sql @@ -363,8 +363,7 @@ ALTER FUNCTION gentoobrowse.filecontent(f files) OWNER TO gentoo; CREATE TABLE filetypes ( filetypeid integer NOT NULL, description text NOT NULL, - spec filterspec[] NOT NULL, - processOrder integer + spec filterspec[] NOT NULL ); ALTER TABLE filetypes OWNER TO gentoo; -- Name: TABLE filetypes; Type: COMMENT; Schema: gentoobrowse; Owner: gentoo diff --git a/gentoobrowse-api/service/maintenancePackageTree.cpp b/gentoobrowse-api/service/maintenancePackageTree.cpp index 5e3d4f4..f5a06de 100644 --- a/gentoobrowse-api/service/maintenancePackageTree.cpp +++ b/gentoobrowse-api/service/maintenancePackageTree.cpp @@ -175,7 +175,11 @@ namespace Gentoo { tp.beforeDelete = boost::bind(&Maintenance::fileDeleted, this, dbc, &fps, tmp, _1); tp.beforeUpdate = boost::bind(&Maintenance::fileChanged, this, dbc, &fps, tmp, _1); tp.beforeInsert = boost::bind(&Maintenance::fileCreated, this, dbc, &fps, tmp, _1); - DB::StaticSqlWriter obpo("processOrder NULLS LAST"); + DB::StaticSqlWriter obpo("CASE \ + WHEN b.fileTypeId = 1 THEN 1 \ + WHEN b.fileTypeId = 10 THEN 2 \ + WHEN b.fileTypeId = 4 THEN 3 \ + END NULLS LAST"); tp.order = &obpo; dbc->patchTable(&tp); for (const auto & fp : fps) { diff --git a/gentoobrowse-api/service/sql/maintenance/fileListCreate.sql b/gentoobrowse-api/service/sql/maintenance/fileListCreate.sql index d8d627c..76d5536 100644 --- a/gentoobrowse-api/service/sql/maintenance/fileListCreate.sql +++ b/gentoobrowse-api/service/sql/maintenance/fileListCreate.sql @@ -3,7 +3,6 @@ SELECT r.repoid, fl.filename, ft.filetypeid, - ft.processOrder, (STRING_TO_ARRAY(fl.filename, '/'))[2:100] pathparts, fl.filesize, fl.filemtime moddate diff --git a/gentoobrowse-api/unittests/basedata.sql b/gentoobrowse-api/unittests/basedata.sql index 6a77ede..e8e3d55 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, processOrder) FROM '$SCRIPTDIR/fixtures/filetypes.dat'; +COPY gentoobrowse.filetypes (filetypeid, description, spec) FROM '$SCRIPTDIR/fixtures/filetypes.dat'; diff --git a/gentoobrowse-api/unittests/data.sql b/gentoobrowse-api/unittests/data.sql index d1c792d..859e16f 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, atomspe 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, processOrder) FROM '$SCRIPTDIR/fixtures/filetypes.dat'; +COPY gentoobrowse.filetypes (filetypeid, description, spec) 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 5d8ed02..5144c64 100644 --- a/gentoobrowse-api/unittests/fixtures/filetypes.dat +++ b/gentoobrowse-api/unittests/fixtures/filetypes.dat @@ -1,11 +1,11 @@ -2 changelog {"(3,ChangeLog)"} \N -3 masks {"(1,profiles)","(2,package.mask)"} \N -7 licenses {"(1,licenses)"} \N -8 manifests {"(3,Manifest)"} \N -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)"} 1 -10 category metadata.xml {"(2,metadata.xml)"} 2 -4 package metadata.xml {"(3,metadata.xml)"} 3 -11 news {"(1,metadata)","(2,news)","(4,%.txt)"} \N +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 ebuild metadata {"(1,metadata)","(2,md5-cache)"} +10 category metadata.xml {"(2,metadata.xml)"} +4 package metadata.xml {"(3,metadata.xml)"} +11 news {"(1,metadata)","(2,news)","(4,%.txt)"} -- cgit v1.2.3