Skip to content

Commit 8bb234a

Browse files
committed
forgot to add the view
1 parent a6eb6cb commit 8bb234a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

couchdb/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,31 @@ When the doc.type map/reduce is in place and the couch_get_dbs_stats.sh has it e
443443
```
444444

445445
Below will return all of the doc types count series for a metric and couch db name:
446+
```
447+
448+
CREATE OR REPLACE VIEW couch_dbs_stats AS
449+
WITH dbs AS (
450+
SELECT abtest.doc ->> 'ts'::text AS "time",
451+
abtest.doc ->> 'name'::text AS metric_name,
452+
json_array_elements((abtest.doc ->> 'dbs'::text)::json) AS adoc
453+
FROM abtest
454+
WHERE (abtest.doc ->> 'type'::text) = 'couch_dbs_stats'::text
455+
), doc_types_counts_working AS (
456+
SELECT dbs."time",
457+
dbs.metric_name,
458+
dbs.adoc ->> 'db_name'::text AS db_name,
459+
json_array_elements((dbs.adoc ->> 'doc_types_count'::text)::json) AS mdoc
460+
FROM dbs
461+
WHERE (dbs.adoc ->> 'doc_types_count'::text) IS NOT NULL
462+
)
463+
SELECT doc_types_counts_working."time",
464+
doc_types_counts_working.metric_name,
465+
doc_types_counts_working.db_name,
466+
json_object_keys(doc_types_counts_working.mdoc) AS doc_type,
467+
doc_types_counts_working.mdoc ->> json_object_keys(doc_types_counts_working.mdoc) AS doc_count
468+
FROM doc_types_counts_working;
469+
```
470+
446471
```
447472
CREATE OR REPLACE FUNCTION get_couch_dbs_doc_type_counts(metricname TEXT, dbname TEXT)
448473
RETURNS text AS

0 commit comments

Comments
 (0)