diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-21 00:28:32 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-25 21:27:48 +0100 |
commit | cd688dbc73f1470daf4abb609d38f8ca7da5c3fc (patch) | |
tree | eb3180edab35e5cc7270e80711e0a9d956ee83b7 | |
parent | Ingest package declarations from manifests (diff) | |
download | gentoobrowse-api-cd688dbc73f1470daf4abb609d38f8ca7da5c3fc.tar.bz2 gentoobrowse-api-cd688dbc73f1470daf4abb609d38f8ca7da5c3fc.tar.xz gentoobrowse-api-cd688dbc73f1470daf4abb609d38f8ca7da5c3fc.zip |
Add textclean function
-rw-r--r-- | gentoobrowse-api/db/schema.sql | 9 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/maintenance/categoryInsert.sql | 2 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/gentoobrowse-api/db/schema.sql b/gentoobrowse-api/db/schema.sql index 4222c8e..105ce3f 100644 --- a/gentoobrowse-api/db/schema.sql +++ b/gentoobrowse-api/db/schema.sql @@ -46,6 +46,15 @@ BEGIN END $$; ALTER FUNCTION gentoobrowse.bugfts(b bugs) OWNER TO gentoo; +-- Name: textclean(text); Type: FUNCTION; Schema: gentoobrowse; Owner: gentoo +CREATE FUNCTION textclean(t text) RETURNS text + LANGUAGE plpgsql IMMUTABLE + AS $$ +BEGIN + RETURN TRIM(REGEXP_REPLACE(t, '\s+', ' ', 'g')); +END +$$; +ALTER FUNCTION gentoobrowse.textclean(t text) OWNER TO gentoo; -- Name: ebuildfilter(text); Type: FUNCTION; Schema: gentoobrowse; Owner: gentoo CREATE FUNCTION ebuildfilter(atomspec text) RETURNS SETOF integer LANGUAGE plpgsql diff --git a/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql index 8c3f685..fa8a1ca 100644 --- a/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql +++ b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql @@ -1,2 +1,2 @@ INSERT INTO gentoobrowse.categories(summary, name) -VALUES(?, ?) +VALUES(gentoobrowse.textclean(?), ?) diff --git a/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql index 1b0ef38..28c45b1 100644 --- a/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql +++ b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql @@ -1,3 +1,3 @@ UPDATE gentoobrowse.categories SET - summary = ? + summary = gentoobrowse.textclean(?) WHERE name = ? |