Skip to content

Commit a25d8bf

Browse files
Fix migrations (#579)
1 parent c7dc430 commit a25d8bf

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

ddl/functions/compute_user_score.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ create or replace function compute_user_score(
1616
chat_block_count bigint,
1717
following_count bigint,
1818
is_audius_impersonator boolean,
19+
has_profile_picture boolean,
1920
distinct_tracks_played bigint,
20-
karma bigint,
21-
has_profile_picture boolean
21+
karma bigint
2222
) returns bigint as $$
2323
select (play_count / 2) + follower_count - challenge_count - (chat_block_count * 100) + karma + case
2424
when following_count < 5 then -1

ddl/functions/get_user_score.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-- identical to get_user_scores but for a single user
22
-- used to generate a user score for attestations and in UI tool
3-
drop function if exists get_user_score(integer);
43
create or replace function get_user_score(target_user_id integer) returns table(
54
-- order matters
65
user_id integer,
@@ -12,6 +11,7 @@ create or replace function get_user_score(target_user_id integer) returns table(
1211
follower_count bigint,
1312
chat_block_count bigint,
1413
is_audius_impersonator boolean,
14+
has_profile_picture boolean,
1515
karma bigint,
1616
score bigint
1717
) language sql as $function$ with play_activity as (
@@ -54,7 +54,6 @@ create or replace function get_user_score(target_user_id integer) returns table(
5454
coalesce(au.following_count, 0) as following_count,
5555
coalesce(au.follower_count, 0) as follower_count,
5656
coalesce(cb.block_count, 0) as chat_block_count,
57-
(u.profile_picture_sizes is not null) as has_profile_picture,
5857
case
5958
when (
6059
u.handle_lc ilike '%audius%'
@@ -63,6 +62,7 @@ create or replace function get_user_score(target_user_id integer) returns table(
6362
and u.is_verified = false then true
6463
else false
6564
end as is_audius_impersonator,
65+
(u.profile_picture_sizes is not null) as has_profile_picture,
6666
case
6767
when (
6868
-- give max karma to users with more than 1000 followers
@@ -100,9 +100,9 @@ select a.*,
100100
a.chat_block_count,
101101
a.following_count,
102102
a.is_audius_impersonator,
103+
a.has_profile_picture,
103104
a.distinct_tracks_played,
104-
a.karma,
105-
a.has_profile_picture
105+
a.karma
106106
) as score
107107
from aggregate_scores a;
108108
$function$;

ddl/functions/get_user_scores.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- identical to get_user_score but for a user batch
22
-- used for updating score in aggregate_user
33
-- this score is used in shadowbanning
4-
drop function if exists get_user_scores(integer []);
54
create or replace function get_user_scores(
65
target_user_ids integer [] default null::integer []
76
) returns table(
@@ -14,6 +13,7 @@ create or replace function get_user_scores(
1413
challenge_count bigint,
1514
chat_block_count bigint,
1615
is_audius_impersonator boolean,
16+
has_profile_picture boolean,
1717
karma bigint,
1818
score bigint
1919
) language sql as $function$ with play_activity as (
@@ -63,7 +63,6 @@ create or replace function get_user_scores(
6363
coalesce(aggregate_user.follower_count, 0) as follower_count,
6464
coalesce(fast_challenge_completion.challenge_count, 0) as challenge_count,
6565
coalesce(chat_blocks.block_count, 0) as chat_block_count,
66-
(users.profile_picture_sizes is not null) as has_profile_picture,
6766
case
6867
when (
6968
users.handle_lc ilike '%audius%'
@@ -72,6 +71,7 @@ create or replace function get_user_scores(
7271
and users.is_verified = false then true
7372
else false
7473
end as is_audius_impersonator,
74+
(users.profile_picture_sizes is not null) as has_profile_picture,
7575
case
7676
when (
7777
-- give max karma to users with more than 1000 followers
@@ -112,9 +112,9 @@ select a.*,
112112
a.chat_block_count,
113113
a.following_count,
114114
a.is_audius_impersonator,
115+
a.has_profile_picture,
115116
a.distinct_tracks_played,
116-
a.karma,
117-
a.has_profile_picture
117+
a.karma
118118
) as score
119119
from aggregate_scores a;
120120
$function$;

0 commit comments

Comments
 (0)