Repository: gratipay/gratipay.com

Issue:
show 140 chars of "Statement" when you mouseover someone's card
There should be a nice way to browse around for people you'd like to support. One easy-to-implement and unobtrusive way to do this would be to show the first 140 chars or so of the person's Statement when you mouseover their card on the homepage or community page. 



Discussion:
+1

Interesting! This would be nice to have, so you don't necessarily have to click through to their profile page.

Seems cool! Will take a stab at this.

Also, what’s the convention when adding new interaction with existing solutions out there? Do we want to write our own or using an existing solution? There are plenty of jQuery tooltip plugins out there for this (though might require some modification to display 140 characters pleasantly).


Resolving patch:
diff --git a/gittip/utils/__init__.py b/gittip/utils/__init__.py
--- a/gittip/utils/__init__.py
+++ b/gittip/utils/__init__.py
@@ -378,8 +378,8 @@ def update_homepage_queries_once(db):
         cursor.execute("DELETE FROM homepage_top_givers")
         cursor.execute("""
 
-        INSERT INTO homepage_top_givers (username, anonymous, amount, avatar_url)
-            SELECT tipper, anonymous_giving, sum(amount) AS amount, avatar_url
+        INSERT INTO homepage_top_givers (username, anonymous, amount, avatar_url, statement, number)
+            SELECT tipper, anonymous_giving, sum(amount) AS amount, avatar_url, statement, number
               FROM (    SELECT DISTINCT ON (tipper, tippee)
                                amount
                              , tipper
@@ -395,7 +395,7 @@ def update_homepage_queries_once(db):
                       ) AS foo
               JOIN participants p ON p.username = tipper
              WHERE is_suspicious IS NOT true
-          GROUP BY tipper, anonymous_giving, avatar_url
+          GROUP BY tipper, anonymous_giving, avatar_url, statement, number
           ORDER BY amount DESC
              LIMIT 100;
 
@@ -404,8 +404,8 @@ def update_homepage_queries_once(db):
         cursor.execute("DELETE FROM homepage_top_receivers")
         cursor.execute("""
 
-        INSERT INTO homepage_top_receivers (username, anonymous, amount, avatar_url)
-            SELECT tippee, anonymous_receiving, sum(amount) AS amount, avatar_url
+        INSERT INTO homepage_top_receivers (username, anonymous, amount, avatar_url, statement, number)
+            SELECT tippee, anonymous_receiving, sum(amount) AS amount, avatar_url, statement, number
               FROM (    SELECT DISTINCT ON (tipper, tippee)
                                amount
                              , tippee
@@ -420,7 +420,7 @@ def update_homepage_queries_once(db):
                       ) AS foo
               JOIN participants p ON p.username = tippee
              WHERE is_suspicious IS NOT true
-          GROUP BY tippee, anonymous_receiving, avatar_url
+          GROUP BY tippee, anonymous_receiving, avatar_url, statement, number
           ORDER BY amount DESC
              LIMIT 100;
 
@@ -468,3 +468,15 @@ def _to_age(participant):
 def format_money(money):
     format = '%.2f' if money < 1000 else '%.0f'
     return format % money
+
+def to_statement(prepend, string, length=140, append='...'):
+    if prepend and string:
+        statement = prepend + string
+        if len(string) > length:
+            return statement[:length] + append
+        elif len(string) > 0:
+            return statement
+        else:
+            return string
+    else:
+        return ''


Test patch: