summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/db/schema.sql9
-rw-r--r--gentoobrowse-api/service/sql/maintenance/categoryInsert.sql2
-rw-r--r--gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql2
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 = ?