Browse Source

fix ratings

Michael Ekstrand 2 months ago
parent
commit
a0ea373bf7
4 changed files with 12 additions and 10 deletions
  1. 1
    1
      Dvcfile
  2. 4
    4
      index/gr-index-ratings.dvc
  3. 3
    1
      index/gr-index-ratings.sql
  4. 4
    4
      integrate/author-stats.dvc

+ 1
- 1
Dvcfile

@@ -6,7 +6,7 @@ deps:
 - path: pgstat://author-info
   md5: 1276cdd4578b084c3b77103d7320b310
 - path: pgstat://author-stats
-  md5: 5554974d660e2b104184535f00107ec3
+  md5: 08a20b852735675f2f2d2a4255d42011
 - path: pgstat://cluster-stats
   md5: 7c052a1b981bcc763cad9abde972639e
 - path: pgstat://loc-mds-index-names

+ 4
- 4
index/gr-index-ratings.dvc

@@ -1,8 +1,8 @@
-md5: e2b85332d16a2008da20430458678f95
+md5: 463c9683e536dda782fed7d5ff97db1a
 cmd: python ../run.py sql-script gr-index-ratings.sql
 deps:
 - path: gr-index-ratings.sql
-  md5: 8e47bd4ca8c1d68ad3b5b708baab1ff9
+  md5: 3ab0a81a10a080e76108eb37aabd3394
 - path: pgstat://gr-interactions
   md5: acf7d8bdbf506c81f6c3ea4eded3d702
 - path: pgstat://cluster
@@ -12,6 +12,6 @@ deps:
 outs:
 - path: pgstat://gr-index-ratings
   cache: false
-  md5: 447f8a6cf359e5d8ae5736cf9863192f
+  md5: 7775e386f896723a35a30baeaa4c9eeb
 - path: gr-index-ratings.transcript
-  md5: d33fdfeca1ebee91120851434a42960c
+  md5: ba049a38c5ee933c391b48cf428f087b

+ 3
- 1
index/gr-index-ratings.sql

@@ -66,7 +66,9 @@ ANALYZE gr.rating;
 --- #step Extract add actions
 CREATE MATERIALIZED VIEW IF NOT EXISTS gr.add_action
   AS SELECT gr_user_rid AS user_id, cluster AS book_id,
-            COUNT(rating) AS nactions,
+            MEDIAN(rating) AS med_rating,
+            (array_agg(rating ORDER BY date_updated DESC))[1] AS last_rating,
+            COUNT(date_updated) AS nactions,
             MIN(EXTRACT(EPOCH FROM date_updated)) AS first_time,
             MAX(EXTRACT(EPOCH FROM date_updated)) AS last_time
      FROM gr.interaction

+ 4
- 4
integrate/author-stats.dvc

@@ -1,4 +1,4 @@
-md5: d6b4f8617938f087c8f79044394873b6
+md5: 34b50f337663ab0810c453a91b872933
 cmd: python ../run.py sql-script author-stats.sql
 deps:
 - path: author-stats.sql
@@ -10,10 +10,10 @@ deps:
 - path: pgstat://az-index
   md5: b845cbb28bd6735919d6ef20c069b2d1
 - path: pgstat://gr-index-ratings
-  md5: 447f8a6cf359e5d8ae5736cf9863192f
+  md5: 7775e386f896723a35a30baeaa4c9eeb
 outs:
 - path: pgstat://author-stats
   cache: false
-  md5: 5554974d660e2b104184535f00107ec3
+  md5: 08a20b852735675f2f2d2a4255d42011
 - path: author-stats.transcript
-  md5: 0a1929d0eb953520c312fefc79de7b94
+  md5: ed88de0cd39767f182e81c7cb36bf4ad