Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

karma chameleon

  • Loading branch information...
commit c4b00123b0cd2612f1f7b142f58b3afecb308b76 1 parent a67f587
Justine Tunney authored
Showing with 23 additions and 7 deletions.
  1. +23 −7 recalculate.sh
View
30 recalculate.sh
@@ -17,19 +17,35 @@ cat <<EOF | psql -q $DB
update occupywallst_comment as C
set ups = coalesce((select count(*)
- from occupywallst_commentvote
- where comment_id = C.id and vote = 1), 0),
+ from occupywallst_commentvote as CV
+ inner join occupywallst_userinfo as UI
+ on CV.user_id = UI.user_id
+ where comment_id = C.id
+ and is_shadow_banned = false
+ and vote = 1), 0),
downs = coalesce((select count(*)
- from occupywallst_commentvote
- where comment_id = C.id and vote = -1), 0),
+ from occupywallst_commentvote as CV
+ inner join occupywallst_userinfo as UI
+ on CV.user_id = UI.user_id
+ where comment_id = C.id
+ and is_shadow_banned = false
+ and vote = -1), 0),
karma = coalesce((select sum(vote)
- from occupywallst_commentvote
- where comment_id = C.id), 0);
+ from occupywallst_commentvote as CV
+ inner join occupywallst_userinfo as UI
+ on CV.user_id = UI.user_id
+ where comment_id = C.id
+ and is_shadow_banned = false), 0)
+ where published > now() - interval '30 day';
update occupywallst_userinfo as U
set karma = coalesce((select sum(karma)
from occupywallst_comment as C
where C.user_id = U.user_id
- and not is_removed), 0);
+ and not is_removed
+ and not is_deleted), 0)
+ where U.user_id in (select distinct(user_id)
+ from occupywallst_comment
+ where published > now() - interval '30 day');
EOF
Please sign in to comment.
Something went wrong with that request. Please try again.