From eed30a287b07d16c92e1b1712ef2b570f350854e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Aug 2015 23:24:46 +0100 Subject: Do category metadata inline --- gentoobrowse/console/categorymetadata.xml | 36 ------------------------------- gentoobrowse/console/packageimport.xml | 12 +++++++++-- gentoobrowse/datasources/schema.sql | 3 +-- 3 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 gentoobrowse/console/categorymetadata.xml diff --git a/gentoobrowse/console/categorymetadata.xml b/gentoobrowse/console/categorymetadata.xml deleted file mode 100644 index 780b2ba..0000000 --- a/gentoobrowse/console/categorymetadata.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - SELECT c.categoryid, 'file://' || ft.searchroot || f.filename AS path, f.moddate - FROM categories c, files f, filetypes ft - WHERE (c.metadatadate IS NULL OR c.metadatadate != f.moddate) - AND f.filename = c.name || '/metadata.xml' - AND f.filetypeid = ft.filetypeid - AND ft.filetypeid = 4 - - - - - - - - - - - - - - - - - UPDATE categories SET - summary = , - metadatadate = - WHERE categoryid = - - - - - diff --git a/gentoobrowse/console/packageimport.xml b/gentoobrowse/console/packageimport.xml index 7a98ef9..04375ca 100644 --- a/gentoobrowse/console/packageimport.xml +++ b/gentoobrowse/console/packageimport.xml @@ -2,9 +2,18 @@ - SELECT DISTINCT pathparts[3] AS name FROM files WHERE filetypeid = 1 + + SELECT c.name, m.summary + FROM (SELECT DISTINCT pathparts[3] AS name FROM files WHERE filetypeid = 1) c + LEFT OUTER JOIN ( + SELECT f.pathparts[1] AS name, RANK() OVER(PARTITION BY f.pathparts[1] ORDER BY repoid DESC) r, + TRIM(REGEXP_REPLACE(CAST((XPATH('/catmetadata/longdescription[@lang="en"]/text()', doc))[1] AS TEXT), '\s+', ' ', 'g')) summary + FROM files f, XMLPARSE(DOCUMENT pg_read_file(filename)) doc + WHERE filetypeid = 10) m ON m.name = c.name + + @@ -190,7 +199,6 @@ - diff --git a/gentoobrowse/datasources/schema.sql b/gentoobrowse/datasources/schema.sql index ffe4111..83ee5a3 100644 --- a/gentoobrowse/datasources/schema.sql +++ b/gentoobrowse/datasources/schema.sql @@ -257,8 +257,7 @@ ALTER OPERATOR gentoobrowse.~ (text[], filterspec[]) OWNER TO postgres; CREATE TABLE categories ( categoryid integer NOT NULL, name text, - summary text, - metadatadate timestamp without time zone + summary text ); ALTER TABLE categories OWNER TO gentoo; -- Name: TABLE categories; Type: COMMENT; Schema: gentoobrowse; Owner: gentoo -- cgit v1.2.3