evt-message_store-postgres-database 0.4.1.0 → 0.5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 604e3e9dd41d52af97049bce34b923de1f54d7295ca225de0cc1ce7cc4476dc6
4
- data.tar.gz: 4c8f7eddd2654732b7b8173af70c45f8eb7ae48eaf82f064a79d6c51963c79d6
3
+ metadata.gz: c588c659a4212dc17462524446f968ccddf10998e8ac7d3c4a6ed0df4f76aba7
4
+ data.tar.gz: b1d06c04be9d5098f76084b6f2bd676fdc91888feadc03d23d26e76d59ace978
5
5
  SHA512:
6
- metadata.gz: 8edddd7a0cc4d9bd68e6b1db51a576196703fe4afce43886cdb03909664ffdbff1f1e266ca1ba7f6c78cd391734e7063de756db927250e519acd070f26300f8d
7
- data.tar.gz: 2833db92e4a33d1f0a193aeadbddb4739d92e4b9254103f5f2be97c31e5068bd66f69ebfd81f8775661d7b9287efc7d5d80fed56adcbce996b93d821bee3edc3
6
+ metadata.gz: 0bc24c1182bf2c4db4c9b0da6b9011a33f3592307d53c8c7eec1a89759f6d41dbf028bf7b301d124bd1e3dc64787e35de008ede6c82c3ddd51ba63aca6e65176
7
+ data.tar.gz: 5292fc4bbfc8ccdaa5578f146dfcf2f46ce0b75d93021f8df88528878ac1821995affba56900323df1ab12501f6976ba922ed8202f295db170728ffd52397bfb
@@ -11,23 +11,31 @@ DECLARE
11
11
  command text;
12
12
  BEGIN
13
13
  command := '
14
- SELECT
15
- stream_name,
16
- message_count,
17
- ROUND((SELECT (message_count::decimal / count(*)::decimal * 100.0) FROM messages)::decimal, 2) AS percent
18
- FROM
19
- (
14
+ WITH
15
+ stream_count AS (
20
16
  SELECT
21
- DISTINCT stream_name,
22
- count(stream_name) AS message_count
17
+ stream_name,
18
+ COUNT(id) AS message_count
23
19
  FROM
24
- messages';
25
-
26
- command := command || '
20
+ messages
27
21
  GROUP BY
28
22
  stream_name
29
- ) summary';
23
+ ),
30
24
 
25
+ total_count AS (
26
+ SELECT
27
+ COUNT(id)::decimal AS total_count
28
+ FROM
29
+ messages
30
+ )
31
+
32
+ SELECT
33
+ stream_name,
34
+ message_count,
35
+ ROUND((message_count / total_count)::decimal * 100, 2) AS percent
36
+ FROM
37
+ stream_count,
38
+ total_count';
31
39
 
32
40
  IF _stream_name is not null THEN
33
41
  _stream_name := '%' || _stream_name || '%';
@@ -11,23 +11,31 @@ DECLARE
11
11
  command text;
12
12
  BEGIN
13
13
  command := '
14
- SELECT
15
- type,
16
- message_count,
17
- ROUND((SELECT (message_count::decimal / count(*)::decimal * 100.0) FROM messages)::decimal, 2) AS percent
18
- FROM
19
- (
14
+ WITH
15
+ type_count AS (
20
16
  SELECT
21
- DISTINCT type,
22
- count(type) AS message_count
17
+ type,
18
+ COUNT(id) AS message_count
23
19
  FROM
24
- messages';
25
-
26
- command := command || '
20
+ messages
27
21
  GROUP BY
28
22
  type
29
- ) summary';
23
+ ),
30
24
 
25
+ total_count AS (
26
+ SELECT
27
+ COUNT(id)::decimal AS total_count
28
+ FROM
29
+ messages
30
+ )
31
+
32
+ SELECT
33
+ type,
34
+ message_count,
35
+ ROUND((message_count / total_count)::decimal * 100, 2) AS percent
36
+ FROM
37
+ type_count,
38
+ total_count';
31
39
 
32
40
  IF _type is not null THEN
33
41
  _type := '%' || _type || '%';
@@ -22,12 +22,12 @@ else
22
22
  fi
23
23
  echo "Database name is: $database"
24
24
 
25
- if [ -z ${STREAM_NAME+x} ]; then
26
- echo "(STREAM_NAME is not set)"
27
- stream_name=''
25
+ if [ -z ${TYPE+x} ]; then
26
+ echo "(TYPE is not set)"
27
+ type=''
28
28
  else
29
- stream_name=$STREAM_NAME
30
- echo "Stream name is: $STREAM_NAME"
29
+ type=$TYPE
30
+ echo "Stream name is: $TYPE"
31
31
  fi
32
32
 
33
33
  echo
@@ -35,10 +35,10 @@ echo "Type Summary"
35
35
  echo "= = ="
36
36
  echo
37
37
 
38
- if [ -z $stream_name ]; then
38
+ if [ -z $type ]; then
39
39
  psql $database -U $user -P pager=off -c "SELECT * FROM get_type_summary();"
40
40
  psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages;"
41
41
  else
42
- psql $database -U $user -P pager=off -c "SELECT * FROM get_type_summary('$stream_name');"
43
- psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages WHERE stream_name LIKE '%$stream_name%';"
42
+ psql $database -U $user -P pager=off -c "SELECT * FROM get_type_summary('$type');"
43
+ psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages WHERE type LIKE '%$type%';"
44
44
  fi
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-message_store-postgres-database
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1.0
4
+ version: 0.5.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-18 00:00:00.000000000 Z
11
+ date: 2018-07-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " "
14
14
  email: opensource@eventide-project.org