Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Modify queries to use is_suspicious (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 8, 2012
1 parent 270894a commit b49ead9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions gittip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def get_dollars_receiving(participant_id):
JOIN participants p ON p.id = tipper
WHERE tippee=%s
AND last_bill_result = ''
AND is_suspicious IS NOT true
ORDER BY tipper
, mtime DESC
) AS foo
Expand Down Expand Up @@ -106,6 +107,7 @@ def get_dollars_giving(participant_id):
JOIN participants p ON p.id = tippee
WHERE tipper=%s
AND last_bill_result = ''
AND is_suspicious IS NOT true
ORDER BY tippee
, mtime DESC
) AS foo
Expand Down Expand Up @@ -137,6 +139,7 @@ def get_number_of_backers(participant_id):
JOIN participants p ON p.id = tipper
WHERE tippee=%s
AND last_bill_result = ''
AND is_suspicious IS NOT true
ORDER BY tipper
, mtime DESC
) AS foo
Expand Down Expand Up @@ -167,6 +170,7 @@ def get_chart_of_giving(user):
JOIN participants p ON p.id = tipper
WHERE tippee=%s
AND last_bill_result = ''
AND is_suspicious IS NOT true
ORDER BY tipper
, mtime DESC
) AS foo
Expand Down
2 changes: 1 addition & 1 deletion www/about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
^L
if not user.ANON:
username = user.id
nparticipants = db.fetchone("SELECT count(*) AS n FROM participants WHERE claimed_time IS NOT NULL")['n']
nparticipants = db.fetchone("SELECT count(*) AS n FROM participants WHERE claimed_time IS NOT NULL AND is_suspicious IS NOT true")['n']
title = "About"
^L
{% extends templates/base.html %}
Expand Down
14 changes: 10 additions & 4 deletions www/about/stats
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ title = "Stats"
yesterday = datetime.datetime.utcnow() - datetime.timedelta(hours=24)
escrow = db.fetchone("SELECT sum(balance) FROM participants")['sum']
escrow = 0 if escrow is None else escrow
nach = db.fetchone("SELECT count(*) AS n FROM participants WHERE last_ach_result = ''")['n']
nach = db.fetchone("SELECT count(*) AS n FROM participants WHERE last_ach_result = '' AND is_suspicious IS NOT true")['n']
nach = 0 if nach is None else nach
if nach < 10:
nach = CARDINALS[nach].title()
Expand All @@ -28,11 +28,11 @@ else:
payday = db.fetchone( "SELECT ts_start, ts_end FROM paydays WHERE ts_start > %s"
, (yesterday,)
)
npeople = db.fetchone("SELECT count(*) AS n FROM participants WHERE claimed_time IS NOT NULL")['n']
ncc = db.fetchone("SELECT count(*) AS n FROM participants WHERE last_bill_result = ''")['n']
npeople = db.fetchone("SELECT count(*) AS n FROM participants WHERE claimed_time IS NOT NULL AND is_suspicious IS NOT true")['n']
ncc = db.fetchone("SELECT count(*) AS n FROM participants WHERE last_bill_result = '' AND is_suspicious IS NOT true")['n']
ncc = 0 if ncc is None else ncc
pcc = "%5.1f" % ((ncc * 100.0) / npeople) if npeople > 0 else 0.0
statements = db.fetchall("SELECT id, statement FROM participants WHERE statement != '' ORDER BY random(), id LIMIT 500")
statements = db.fetchall("SELECT id, statement FROM participants WHERE statement != '' AND is_suspicious IS NOT true ORDER BY random(), id LIMIT 500")
statements = [] if statements is None else list(statements)
transfer_volume = db.fetchone("SELECT transfer_volume AS v FROM paydays ORDER BY ts_end DESC LIMIT 1")
transfer_volume = 0 if transfer_volume is None else transfer_volume['v']
Expand All @@ -44,6 +44,8 @@ tip_amounts = db.fetchone("""
JOIN participants p2 ON p2.id = tippee
WHERE p.last_bill_result = ''
AND p2.claimed_time IS NOT NULL
AND p.is_suspicious IS NOT true
AND p2.is_suspicious IS NOT true
ORDER BY tipper, tippee, mtime DESC
) AS foo;
""")
Expand All @@ -66,6 +68,8 @@ average_tippees = db.fetchone("""\
JOIN participants p2 on p2.id = tippee
WHERE p.last_bill_result = ''
AND p2.claimed_time IS NOT NULL
AND NOT (p.is_suspicious IS true)
AND NOT (p2.is_suspicious IS true)
GROUP BY tipper, tippee, mtime, amount
ORDER BY tipper, tippee, mtime DESC
) AS foo WHERE amount > 0 GROUP BY tipper) AS bar
Expand Down Expand Up @@ -94,6 +98,8 @@ _tip_distribution = list(db.fetchall("""
JOIN participants p2 on p2.id = tippee
WHERE p.last_bill_result = ''
AND p2.claimed_time IS NOT NULL
AND NOT (p.is_suspicious IS true)
AND NOT (p2.is_suspicious IS true)
AND amount > 0
GROUP BY tipper, tippee, mtime, amount
ORDER BY tipper, tippee, mtime DESC
Expand Down
2 changes: 2 additions & 0 deletions www/about/unclaimed.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
JOIN social_network_users snu ON snu.participant_id = tippee
WHERE p.last_bill_result = ''
AND p2.claimed_time IS NULL
AND p.is_suspicious IS NOT true
AND p2.is_suspicious IS NOT true
AND snu.is_locked = false
ORDER BY tipper, tippee, mtime DESC
) AS foo
Expand Down
5 changes: 4 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
JOIN social_network_users snu ON snu.participant_id = tippee
WHERE last_bill_result = ''
AND snu.is_locked = false
AND is_suspicious IS NOT true
ORDER BY tipper, tippee, mtime DESC
) AS foo
JOIN participants p ON p.id = tippee
WHERE is_suspicious IS NOT true
GROUP BY tippee, claimed_time
ORDER BY amount DESC
LIMIT %s
Expand All @@ -39,11 +41,12 @@
JOIN participants p ON p.id = tipper
JOIN social_network_users snu ON snu.participant_id = tippee
WHERE last_bill_result = ''
AND ((is_suspicious IS false) OR (is_suspicious IS NULL))
AND is_suspicious IS NOT true
AND snu.is_locked = false
ORDER BY tipper, tippee, mtime DESC
) AS foo
JOIN participants p ON p.id = tipper
WHERE is_suspicious IS NOT true
GROUP BY tipper, anonymous
ORDER BY amount DESC
LIMIT %s
Expand Down

0 comments on commit b49ead9

Please sign in to comment.