From b49ead93182eda1e2db4a06ad2e81e6037cc15cc Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 8 Nov 2012 09:43:25 -0500 Subject: [PATCH] Modify queries to use is_suspicious (#354) --- gittip/__init__.py | 4 ++++ www/about/index.html | 2 +- www/about/stats | 14 ++++++++++---- www/about/unclaimed.html | 2 ++ www/index.html | 5 ++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gittip/__init__.py b/gittip/__init__.py index 74a2ec6b89..b797c18b14 100644 --- a/gittip/__init__.py +++ b/gittip/__init__.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/www/about/index.html b/www/about/index.html index 0ca7bc6fcd..914ae5a5e9 100644 --- a/www/about/index.html +++ b/www/about/index.html @@ -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 %} diff --git a/www/about/stats b/www/about/stats index 57d73dbb33..e05efca121 100644 --- a/www/about/stats +++ b/www/about/stats @@ -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() @@ -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'] @@ -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; """) @@ -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 @@ -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 diff --git a/www/about/unclaimed.html b/www/about/unclaimed.html index 0a8c7d0879..6b477a8652 100644 --- a/www/about/unclaimed.html +++ b/www/about/unclaimed.html @@ -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 diff --git a/www/index.html b/www/index.html index 0b013fd4cb..5d1236c2ec 100644 --- a/www/index.html +++ b/www/index.html @@ -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 @@ -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