evt-message_store-postgres-database 0.6.0.0 → 0.7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3a52a67d61c7b82f6dbdf1859bc19ba5c5cccee8f1b7463aa89fd2395ab7326
4
- data.tar.gz: dd2b045c1bb470c3f5c160c36a0d21090fc522f79563d48abae1f8d7d83df112
3
+ metadata.gz: f2a272743542b920006e450e78e7363c9a2a3ff96026107fcb409b6db99fc14a
4
+ data.tar.gz: db445aabcfe02e49ac4e5fdad14be127298e58ea2903a40ee6d1f19fcb9c703c
5
5
  SHA512:
6
- metadata.gz: 2e934f4216be131a030905f6db71448213b8688256c218379fad8ed46b73c05dbdf08d39c995d5c52e5a1014ebe5fa476ade52842bfbfdf2727e06c46970b5ee
7
- data.tar.gz: 5e98034583a8ea74581ab0d032a619f3c50927e21b9bd430536d1f466c47e89ba9d25a2770c34d21831b2f5a9b1ff2596257b72bfef046049a345b4392415b1d
6
+ metadata.gz: e77348cba57e2bc10d68654fa13aa78a886256ee386f96198dabec6dfc28892ee955fbfca8715df40345cbe5d59b1c2296e23365f9ad9b7b7798ba8a06145c7f
7
+ data.tar.gz: 7d953081cd06b2011b706e985e92ef088ea79452296f71ab26ce9ecd77a3ae5cb4bcc19a04c4c4d2e0f5c95e0932d89781dad3d0166c2012ca912a6a82ab72e6
@@ -32,6 +32,12 @@ function create-views {
32
32
  echo "type_stream_summary view"
33
33
  psql $database -f $base/views/type-stream-summary.sql
34
34
 
35
+ echo "category_type_summary view"
36
+ psql $database -f $base/views/category-type-summary.sql
37
+
38
+ echo "type_category_summary view"
39
+ psql $database -f $base/views/type-category-summary.sql
40
+
35
41
  echo
36
42
  }
37
43
 
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo
6
+
7
+ default_name=message_store
8
+
9
+ if [ -z ${DATABASE_USER+x} ]; then
10
+ echo "(DATABASE_USER is not set)"
11
+ user=$default_name
12
+ else
13
+ user=$DATABASE_USER
14
+ fi
15
+ echo "Database user is: $user"
16
+
17
+ if [ -z ${DATABASE_NAME+x} ]; then
18
+ echo "(DATABASE_NAME is not set)"
19
+ database=$default_name
20
+ else
21
+ database=$DATABASE_NAME
22
+ fi
23
+ echo "Database name is: $database"
24
+
25
+ if [ -z ${CATEGORY+x} ]; then
26
+ echo "(CATEGORY is not set)"
27
+ category=''
28
+ else
29
+ category=$CATEGORY
30
+ echo "Stream name is: $CATEGORY"
31
+ fi
32
+
33
+ echo
34
+ echo "Category Type Summary"
35
+ echo "= = ="
36
+ echo
37
+
38
+ if [ -z $category ]; then
39
+ psql $database -U $user -P pager=off -c "SELECT * FROM category_type_summary;"
40
+ psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages;"
41
+ else
42
+ psql $database -U $user -P pager=off -c "SELECT * FROM category_type_summary WHERE category LIKE '%$category%';"
43
+ psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages WHERE category(stream_name) LIKE '%$category%';"
44
+ fi
@@ -31,7 +31,7 @@ else
31
31
  fi
32
32
 
33
33
  echo
34
- echo "Stream Stream Summary"
34
+ echo "Stream Type Summary"
35
35
  echo "= = ="
36
36
  echo
37
37
 
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo
6
+
7
+ default_name=message_store
8
+
9
+ if [ -z ${DATABASE_USER+x} ]; then
10
+ echo "(DATABASE_USER is not set)"
11
+ user=$default_name
12
+ else
13
+ user=$DATABASE_USER
14
+ fi
15
+ echo "Database user is: $user"
16
+
17
+ if [ -z ${DATABASE_NAME+x} ]; then
18
+ echo "(DATABASE_NAME is not set)"
19
+ database=$default_name
20
+ else
21
+ database=$DATABASE_NAME
22
+ fi
23
+ echo "Database name is: $database"
24
+
25
+ if [ -z ${TYPE+x} ]; then
26
+ echo "(TYPE is not set)"
27
+ type=''
28
+ else
29
+ type=$TYPE
30
+ echo "Type is: $TYPE"
31
+ fi
32
+
33
+ echo
34
+ echo "Type Category Summary"
35
+ echo "= = ="
36
+ echo
37
+
38
+ if [ -z $type ]; then
39
+ psql $database -U $user -P pager=off -c "SELECT * FROM type_category_summary;"
40
+ psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages;"
41
+ else
42
+ psql $database -U $user -P pager=off -c "SELECT * FROM type_category_summary WHERE type LIKE '%$type%';"
43
+ psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages WHERE type LIKE '%$type%';"
44
+ fi
@@ -0,0 +1,32 @@
1
+ CREATE OR REPLACE VIEW category_type_summary AS
2
+ WITH
3
+ type_count AS (
4
+ SELECT
5
+ category(stream_name) AS category,
6
+ type,
7
+ COUNT(id) AS message_count
8
+ FROM
9
+ messages
10
+ GROUP BY
11
+ category,
12
+ type
13
+ ),
14
+
15
+ total_count AS (
16
+ SELECT
17
+ COUNT(id)::decimal AS total_count
18
+ FROM
19
+ messages
20
+ )
21
+
22
+ SELECT
23
+ category,
24
+ type,
25
+ message_count,
26
+ ROUND((message_count / total_count)::decimal * 100, 2) AS percent
27
+ FROM
28
+ type_count,
29
+ total_count
30
+ ORDER BY
31
+ category,
32
+ type;
@@ -0,0 +1,32 @@
1
+ CREATE OR REPLACE VIEW type_category_summary AS
2
+ WITH
3
+ type_count AS (
4
+ SELECT
5
+ type,
6
+ category(stream_name) AS category,
7
+ COUNT(id) AS message_count
8
+ FROM
9
+ messages
10
+ GROUP BY
11
+ type,
12
+ category
13
+ ),
14
+
15
+ total_count AS (
16
+ SELECT
17
+ COUNT(id)::decimal AS total_count
18
+ FROM
19
+ messages
20
+ )
21
+
22
+ SELECT
23
+ type,
24
+ category,
25
+ message_count,
26
+ ROUND((message_count / total_count)::decimal * 100, 2) AS percent
27
+ FROM
28
+ type_count,
29
+ total_count
30
+ ORDER BY
31
+ type,
32
+ category;
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ root = File.expand_path '../database', __dir__
4
+ script_filename = 'install-views.sh'
5
+ script_filepath = File.join root, script_filename
6
+
7
+ system script_filepath
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ root = File.expand_path '../database', __dir__
4
+ script_filename = 'print-category-type-summary.sh'
5
+ script_filepath = File.join root, script_filename
6
+
7
+ system script_filepath
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ root = File.expand_path '../database', __dir__
4
+ script_filename = 'print-type-category-summary.sh'
5
+ script_filepath = File.join root, script_filename
6
+
7
+ system script_filepath
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-message_store-postgres-database
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.0
4
+ version: 0.7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: scripts
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " "
14
14
  email: opensource@eventide-project.org
15
15
  executables:
16
+ - evt-pg-install-functions
16
17
  - evt-pg-print-messages
18
+ - evt-pg-install-views
17
19
  - evt-pg-delete-db
18
20
  - evt-pg-print-stream-type-summary
19
21
  - evt-pg-write-test-message
20
22
  - evt-pg-create-db
21
- - evt-pg-install-database-functions
23
+ - evt-pg-print-type-category-summary
22
24
  - evt-pg-open-database-scripts-dir
23
25
  - evt-pg-clear-messages
24
26
  - evt-pg-recreate-db
27
+ - evt-pg-print-category-type-summary
25
28
  - evt-pg-print-type-stream-summary
26
29
  - evt-pg-print-type-summary
27
30
  - evt-pg-print-stream-summary
@@ -47,27 +50,34 @@ files:
47
50
  - database/install-functions.sh
48
51
  - database/install-views.sh
49
52
  - database/install.sh
53
+ - database/print-category-type-summary.sh
50
54
  - database/print-messages.sh
51
55
  - database/print-stream-summary.sh
52
56
  - database/print-stream-type-summary.sh
57
+ - database/print-type-category-summary.sh
53
58
  - database/print-type-stream-summary.sh
54
59
  - database/print-type-summary.sh
55
60
  - database/table/messages-table.sql
56
61
  - database/types/message.sql
57
62
  - database/uninstall.sh
63
+ - database/views/category-type-summary.sql
58
64
  - database/views/stream-summary.sql
59
65
  - database/views/stream-type-summary.sql
66
+ - database/views/type-category-summary.sql
60
67
  - database/views/type-stream-summary.sql
61
68
  - database/views/type-summary.sql
62
69
  - database/write-test-message.sh
63
70
  - scripts/evt-pg-clear-messages
64
71
  - scripts/evt-pg-create-db
65
72
  - scripts/evt-pg-delete-db
66
- - scripts/evt-pg-install-database-functions
73
+ - scripts/evt-pg-install-functions
74
+ - scripts/evt-pg-install-views
67
75
  - scripts/evt-pg-open-database-scripts-dir
76
+ - scripts/evt-pg-print-category-type-summary
68
77
  - scripts/evt-pg-print-messages
69
78
  - scripts/evt-pg-print-stream-summary
70
79
  - scripts/evt-pg-print-stream-type-summary
80
+ - scripts/evt-pg-print-type-category-summary
71
81
  - scripts/evt-pg-print-type-stream-summary
72
82
  - scripts/evt-pg-print-type-summary
73
83
  - scripts/evt-pg-recreate-db