Skip to content

Commit

Permalink
user metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-dhanwant-yral committed Aug 28, 2024
1 parent b72e3a8 commit 78b2d2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions user_video_relation/ds__user_video_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create_initial_query():
JSON_EXTRACT_SCALAR(params, '$.user_id') AS user_id,
JSON_EXTRACT_SCALAR(params, '$.video_id') AS video_id,
max(timestamp) as last_watched_timestamp,
AVG(CAST(JSON_EXTRACT_SCALAR(params, '$.percentage_watched') AS FLOAT64)) AS mean_percentage_watched
AVG(CAST(JSON_EXTRACT_SCALAR(params, '$.percentage_watched') AS FLOAT64))/100 AS mean_percentage_watched
FROM
analytics_335143420.test_events_analytics -- base analytics table -- change this if the table name changes
WHERE
Expand Down Expand Up @@ -112,7 +112,7 @@ def create_incremental_query(last_timestamp):
JSON_EXTRACT_SCALAR(params, '$.user_id') AS user_id,
JSON_EXTRACT_SCALAR(params, '$.video_id') AS video_id,
max(timestamp) as last_watched_timestamp,
AVG(CAST(JSON_EXTRACT_SCALAR(params, '$.percentage_watched') AS FLOAT64)) AS mean_percentage_watched
AVG(CAST(JSON_EXTRACT_SCALAR(params, '$.percentage_watched') AS FLOAT64))/100 AS mean_percentage_watched
FROM
analytics_335143420.test_events_analytics
WHERE
Expand Down
4 changes: 2 additions & 2 deletions video_statistics/ds__video_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_initial_query():
uvr.user_id,
(1 - IFNULL(user_like_avg, 1)) * CAST(liked AS INT64) AS user_normalized_like_contribution,
(1 - IFNULL(user_share_avg, 1)) * CAST(shared AS INT64) AS user_normalized_share_contribution,
((100 - IFNULL(user_watch_percentage_avg, 100))/100) * mean_percentage_watched AS user_normalized_watch_contribution,
((1 - IFNULL(user_watch_percentage_avg, 1))) * mean_percentage_watched AS user_normalized_watch_contribution,
last_watched_timestamp
FROM
`hot-or-not-feed-intelligence.yral_ds.userVideoRelation` uvr
Expand Down Expand Up @@ -76,7 +76,7 @@ def create_incremental_query():
uvr.user_id,
(1 - IFNULL(user_like_avg, 1)) * CAST(liked AS INT64) AS user_normalized_like_contribution,
(1 - IFNULL(user_share_avg, 1)) * CAST(shared AS INT64) AS user_normalized_share_contribution,
((100 - IFNULL(user_watch_percentage_avg, 100))/100) * mean_percentage_watched AS user_normalized_watch_contribution,
((1 - IFNULL(user_watch_percentage_avg, 1))) * mean_percentage_watched AS user_normalized_watch_contribution,
last_watched_timestamp
FROM
`hot-or-not-feed-intelligence.yral_ds.userVideoRelation` uvr
Expand Down

0 comments on commit 78b2d2f

Please sign in to comment.