word: select mkwordlist forms from _cat_words view
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 25 May 2020 03:24:51 +0000 (05:24 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 6 Jun 2020 01:49:20 +0000 (03:49 +0200)
tools/mkwordlist
tools/word.pg.sql

index bec1362b51b2c6a39cd94a2c75912ca1dc73f48f..d4dfaa245cf8e28e563b4bc4c47f9ca64aefdecd 100755 (executable)
@@ -1,8 +1,4 @@
 #!/bin/sh
 psql sheet -XAt -c "
-       SELECT json_object_agg(coalesce(form, ''), forms)
-               FROM word RIGHT JOIN (
-                       SELECT cat id, array_agg(form ORDER BY form) forms
-                               FROM word WHERE ref IS NULL GROUP BY cat
-               ) sub USING (id)
+       SELECT json_object_agg(coalesce(form, ''), forms) FROM _cat_words
 " | sed 's/:/=>/g'
index 6cab79d2b2f503cc22ccde5aa7c6db323af1c7ed..da22b55311246348d8832e07542511b9aa3815d0 100644 (file)
@@ -19,3 +19,9 @@ COMMENT ON COLUMN word.prio       IS 'difficulty level or importance; lower valu
 COMMENT ON COLUMN word.source     IS 'URI of downloaded image';
 COMMENT ON COLUMN word.thumb      IS 'ImageMagick convert options to create thumbnail from source image';
 COMMENT ON COLUMN word.wptitle    IS 'reference Wikipedia article';
+
+CREATE OR REPLACE VIEW _cat_words AS
+       SELECT * FROM word RIGHT JOIN (
+               SELECT cat id, array_agg(form ORDER BY form) forms
+                       FROM word WHERE ref IS NULL GROUP BY cat
+       ) sub USING (id);