We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
per-user charts are scrunched
After #1711 the per-user charts are scrunched:

![screen shot 2013-12-04 at 9 59 26 am](https://f.cloud.github.com/assets/134455/1674158/e39f7760-5cf4-11e3-86e2-5019fde7231d.png)

cc: @dominic @seanlinsley 

fake_data paydays should include transfers
We have paydays with `make data`, but we don't have any transfers. We need transfers to see the user charts in dev (cf. #1717).

Charts are too wide in mobile browsers
<img width="33%" src="https://f.cloud.github.com/assets/688886/1649646/413a1054-5a18-11e3-8acb-2d1d5da19d72.png"> <img width="33%" src="https://f.cloud.github.com/assets/688886/1649647/413b9956-5a18-11e3-87c7-582ef4525553.png"> <img width="33%" src="https://f.cloud.github.com/assets/688886/1649655/efdc9cbc-5a18-11e3-81a3-9fab62fd0be7.png">


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gittip/utils/fake_data.py`
Content:
```
1 from faker import Factory
2 from gittip import wireup, MAX_TIP, MIN_TIP
3 from gittip.models.participant import Participant
4 
5 import decimal
6 import random
7 import string
8 import datetime
9 
10 
11 faker = Factory.create()
12 
13 platforms = ['github', 'twitter', 'bitbucket']
14 
15 
16 def _fake_thing(db, tablename, **kw):
17     column_names = []
18     column_value_placeholders = []
19     column_values = []
20 
21     for k,v in kw.items():
22         column_names.append(k)
23         column_value_placeholders.append("%s")
24         column_values.append(v)
25 
26     column_names = ", ".join(column_names)
27     column_value_placeholders = ", ".join(column_value_placeholders)
28 
29     db.run( "INSERT INTO {} ({}) VALUES ({})"
30             .format(tablename, column_names, column_value_placeholders)
31           , column_values
32            )
33     return kw
34 
35 
36 def fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):
37     """Create a random text id.
38     """
39     return ''.join(random.choice(chars) for x in range(size))
40 
41 
42 def fake_balance(max_amount=100):
43     """Return a random amount between 0 and max_amount.
44     """
45     return random.random() * max_amount
46 
47 
48 def fake_int_id(nmax=2 ** 31 -1):
49     """Create a random int id.
50     """
51     return random.randint(0, nmax)
52 
53 
54 def fake_participant(db, number="singular", is_admin=False, anonymous=False):
55     """Create a fake User.
56     """
57     username = faker.firstName() + fake_text_id(3)
58     d = _fake_thing( db
59                , "participants"
60                , id=fake_int_id()
61                , username=username
62                , username_lower=username.lower()
63                , statement=faker.sentence()
64                , ctime=faker.dateTimeThisYear()
65                , is_admin=is_admin
66                , balance=fake_balance()
67                , anonymous=anonymous
68                , goal=fake_balance()
69                , balanced_account_uri=faker.uri()
70                , last_ach_result=''
71                , is_suspicious=False
72                , last_bill_result=''  # Needed to not be suspicious
73                , claimed_time=faker.dateTimeThisYear()
74                , number=number
75                 )
76     #Call participant constructor to perform other DB initialization
77     return Participant.from_username(username)
78 
79 
80 
81 def fake_tip_amount():
82     amount = ((decimal.Decimal(random.random()) * (MAX_TIP - MIN_TIP))
83             + MIN_TIP)
84 
85     decimal_amount = decimal.Decimal(amount).quantize(decimal.Decimal('.01'))
86 
87     return decimal_amount
88 
89 
90 def fake_tip(db, tipper, tippee):
91     """Create a fake tip.
92     """
93     return _fake_thing( db
94                , "tips"
95                , id=fake_int_id()
96                , ctime=faker.dateTimeThisYear()
97                , mtime=faker.dateTimeThisMonth()
98                , tipper=tipper.username
99                , tippee=tippee.username
100                , amount=fake_tip_amount()
101                 )
102 
103 
104 def fake_elsewhere(db, participant, platform=None):
105     """Create a fake elsewhere.
106     """
107     if platform is None:
108         platform = random.choice(platforms)
109 
110     info_templates = {
111         "github": {
112             "name": participant.username,
113             "html_url": "https://github.com/" + participant.username,
114             "type": "User",
115             "login": participant.username
116         },
117         "twitter": {
118             "name": participant.username,
119             "html_url": "https://twitter.com/" + participant.username,
120             "screen_name": participant.username
121         },
122         "bitbucket": {
123             "display_name": participant.username,
124             "username": participant.username,
125             "is_team": "False",
126             "html_url": "https://bitbucket.org/" + participant.username,
127         }
128     }
129 
130     _fake_thing( db
131                , "elsewhere"
132                , id=fake_int_id()
133                , platform=platform
134                , user_id=fake_text_id()
135                , is_locked=False
136                , participant=participant.username
137                , user_info=info_templates[platform]
138                 )
139 
140 def fake_transfer(db, tipper, tippee):
141         return _fake_thing( db
142                , "transfers"
143                , id=fake_int_id()
144                , timestamp=faker.dateTimeThisYear()
145                , tipper=tipper.username
146                , tippee=tippee.username
147                , amount=fake_tip_amount()
148                 )
149 
150 
151 def populate_db(db, num_participants=300, num_tips=200, num_teams=5, num_transfers=300):
152     """Populate DB with fake data.
153     """
154     #Make the participants
155     participants = []
156     for i in xrange(num_participants):
157         participants.append(fake_participant(db))
158 
159     #Make the "Elsewhere's"
160     for p in participants:
161         #All participants get between 1 and 3 elsewheres
162         num_elsewheres = random.randint(1, 3)
163         for platform_name in platforms[:num_elsewheres]:
164             fake_elsewhere(db, p, platform_name)
165 
166     #Make teams
167     for i in xrange(num_teams):
168         t = fake_participant(db, number="plural")
169         #Add 1 to 3 members to the team
170         members = random.sample(participants, random.randint(1, 3))
171         for p in members:
172             t.add_member(p)
173 
174     #Make the tips
175     tips = []
176     for i in xrange(num_tips):
177         tipper, tippee = random.sample(participants, 2)
178         tips.append(fake_tip(db, tipper, tippee))
179 
180 
181     #Make the transfers
182     transfers = []
183     for i in xrange(num_tips):
184         tipper, tippee = random.sample(participants, 2)
185         transfers.append(fake_transfer(db, tipper, tippee))
186 
187 
188     #Make some paydays
189     #First determine the boundaries - min and max date
190     min_date = min(min(x['ctime'] for x in tips), \
191                    min(x['timestamp'] for x in transfers))
192     max_date = max(max(x['ctime'] for x in tips), \
193                    max(x['timestamp'] for x in transfers))
194     #iterate through min_date, max_date one week at a time
195     date = min_date
196     while date < max_date:
197         end_date = date + datetime.timedelta(days=7)
198         week_tips = filter(lambda x: date <= x['ctime'] <= end_date, tips)
199         week_transfers = filter(lambda x: date <= x['timestamp'] <= end_date, transfers)
200         week_participants = filter(lambda x: x.ctime.replace(tzinfo=None) <= end_date, participants)
201         actives=set()
202         tippers=set()
203         for xfers in week_tips, week_transfers:
204             actives.update(x['tipper'] for x in xfers)
205             actives.update(x['tippee'] for x in xfers)
206             tippers.update(x['tipper'] for x in xfers)
207         payday = {
208             'id': fake_int_id(),
209             'ts_start': date,
210             'ts_end': end_date,
211             'ntips': len(week_tips),
212             'ntransfers': len(week_transfers),
213             'nparticipants': len(week_participants),
214             'ntippers': len(tippers),
215             'nactive': len(actives),
216             'transfer_volume': sum(x['amount'] for x in week_transfers)
217         }
218         #Make ach_volume and charge_volume between 0 and 10% of transfer volume
219         def rand_part():
220             return decimal.Decimal(random.random()* 0.1)
221         payday['ach_volume']   = -1 * payday['transfer_volume'] * rand_part()
222         payday['charge_volume'] = payday['transfer_volume'] * rand_part()
223         _fake_thing(db, "paydays", **payday)
224         date = end_date
225 
226 
227 
228 def main():
229     populate_db(wireup.db())
230 
231 if __name__ == '__main__':
232     main()
233
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gittip/utils/fake_data.py b/gittip/utils/fake_data.py
--- a/gittip/utils/fake_data.py
+++ b/gittip/utils/fake_data.py
@@ -51,6 +51,12 @@
     return random.randint(0, nmax)
 
 
+def fake_sentence(start=1, stop=100):
+    """Create a sentence of random length.
+    """
+    return faker.sentence(random.randrange(start,stop))
+
+
 def fake_participant(db, number="singular", is_admin=False, anonymous=False):
     """Create a fake User.
     """
@@ -60,7 +66,7 @@
                , id=fake_int_id()
                , username=username
                , username_lower=username.lower()
-               , statement=faker.sentence()
+               , statement=fake_sentence()
                , ctime=faker.dateTimeThisYear()
                , is_admin=is_admin
                , balance=fake_balance()
@@ -148,7 +154,7 @@
                 )
 
 
-def populate_db(db, num_participants=300, num_tips=200, num_teams=5, num_transfers=300):
+def populate_db(db, num_participants=100, num_tips=200, num_teams=5, num_transfers=5000):
     """Populate DB with fake data.
     """
     #Make the participants
@@ -180,7 +186,7 @@
 
     #Make the transfers
     transfers = []
-    for i in xrange(num_tips):
+    for i in xrange(num_transfers):
         tipper, tippee = random.sample(participants, 2)
         transfers.append(fake_transfer(db, tipper, tippee))

{"golden_diff": "diff --git a/gittip/utils/fake_data.py b/gittip/utils/fake_data.py\n--- a/gittip/utils/fake_data.py\n+++ b/gittip/utils/fake_data.py\n@@ -51,6 +51,12 @@\n     return random.randint(0, nmax)\n \n \n+def fake_sentence(start=1, stop=100):\n+    \"\"\"Create a sentence of random length.\n+    \"\"\"\n+    return faker.sentence(random.randrange(start,stop))\n+\n+\n def fake_participant(db, number=\"singular\", is_admin=False, anonymous=False):\n     \"\"\"Create a fake User.\n     \"\"\"\n@@ -60,7 +66,7 @@\n                , id=fake_int_id()\n                , username=username\n                , username_lower=username.lower()\n-               , statement=faker.sentence()\n+               , statement=fake_sentence()\n                , ctime=faker.dateTimeThisYear()\n                , is_admin=is_admin\n                , balance=fake_balance()\n@@ -148,7 +154,7 @@\n                 )\n \n \n-def populate_db(db, num_participants=300, num_tips=200, num_teams=5, num_transfers=300):\n+def populate_db(db, num_participants=100, num_tips=200, num_teams=5, num_transfers=5000):\n     \"\"\"Populate DB with fake data.\n     \"\"\"\n     #Make the participants\n@@ -180,7 +186,7 @@\n \n     #Make the transfers\n     transfers = []\n-    for i in xrange(num_tips):\n+    for i in xrange(num_transfers):\n         tipper, tippee = random.sample(participants, 2)\n         transfers.append(fake_transfer(db, tipper, tippee))\n", "issue": "per-user charts are scrunched\nAfter #1711 the per-user charts are scrunched:\n\n![screen shot 2013-12-04 at 9 59 26 am](https://f.cloud.github.com/assets/134455/1674158/e39f7760-5cf4-11e3-86e2-5019fde7231d.png)\n\ncc: @dominic @seanlinsley \n\nfake_data paydays should include transfers\nWe have paydays with `make data`, but we don't have any transfers. We need transfers to see the user charts in dev (cf. #1717).\n\nCharts are too wide in mobile browsers\n<img width=\"33%\" src=\"https://f.cloud.github.com/assets/688886/1649646/413a1054-5a18-11e3-8acb-2d1d5da19d72.png\"> <img width=\"33%\" src=\"https://f.cloud.github.com/assets/688886/1649647/413b9956-5a18-11e3-87c7-582ef4525553.png\"> <img width=\"33%\" src=\"https://f.cloud.github.com/assets/688886/1649655/efdc9cbc-5a18-11e3-81a3-9fab62fd0be7.png\">\n\n", "before_files": [{"content": "from faker import Factory\nfrom gittip import wireup, MAX_TIP, MIN_TIP\nfrom gittip.models.participant import Participant\n\nimport decimal\nimport random\nimport string\nimport datetime\n\n\nfaker = Factory.create()\n\nplatforms = ['github', 'twitter', 'bitbucket']\n\n\ndef _fake_thing(db, tablename, **kw):\n    column_names = []\n    column_value_placeholders = []\n    column_values = []\n\n    for k,v in kw.items():\n        column_names.append(k)\n        column_value_placeholders.append(\"%s\")\n        column_values.append(v)\n\n    column_names = \", \".join(column_names)\n    column_value_placeholders = \", \".join(column_value_placeholders)\n\n    db.run( \"INSERT INTO {} ({}) VALUES ({})\"\n            .format(tablename, column_names, column_value_placeholders)\n          , column_values\n           )\n    return kw\n\n\ndef fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):\n    \"\"\"Create a random text id.\n    \"\"\"\n    return ''.join(random.choice(chars) for x in range(size))\n\n\ndef fake_balance(max_amount=100):\n    \"\"\"Return a random amount between 0 and max_amount.\n    \"\"\"\n    return random.random() * max_amount\n\n\ndef fake_int_id(nmax=2 ** 31 -1):\n    \"\"\"Create a random int id.\n    \"\"\"\n    return random.randint(0, nmax)\n\n\ndef fake_participant(db, number=\"singular\", is_admin=False, anonymous=False):\n    \"\"\"Create a fake User.\n    \"\"\"\n    username = faker.firstName() + fake_text_id(3)\n    d = _fake_thing( db\n               , \"participants\"\n               , id=fake_int_id()\n               , username=username\n               , username_lower=username.lower()\n               , statement=faker.sentence()\n               , ctime=faker.dateTimeThisYear()\n               , is_admin=is_admin\n               , balance=fake_balance()\n               , anonymous=anonymous\n               , goal=fake_balance()\n               , balanced_account_uri=faker.uri()\n               , last_ach_result=''\n               , is_suspicious=False\n               , last_bill_result=''  # Needed to not be suspicious\n               , claimed_time=faker.dateTimeThisYear()\n               , number=number\n                )\n    #Call participant constructor to perform other DB initialization\n    return Participant.from_username(username)\n\n\n\ndef fake_tip_amount():\n    amount = ((decimal.Decimal(random.random()) * (MAX_TIP - MIN_TIP))\n            + MIN_TIP)\n\n    decimal_amount = decimal.Decimal(amount).quantize(decimal.Decimal('.01'))\n\n    return decimal_amount\n\n\ndef fake_tip(db, tipper, tippee):\n    \"\"\"Create a fake tip.\n    \"\"\"\n    return _fake_thing( db\n               , \"tips\"\n               , id=fake_int_id()\n               , ctime=faker.dateTimeThisYear()\n               , mtime=faker.dateTimeThisMonth()\n               , tipper=tipper.username\n               , tippee=tippee.username\n               , amount=fake_tip_amount()\n                )\n\n\ndef fake_elsewhere(db, participant, platform=None):\n    \"\"\"Create a fake elsewhere.\n    \"\"\"\n    if platform is None:\n        platform = random.choice(platforms)\n\n    info_templates = {\n        \"github\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://github.com/\" + participant.username,\n            \"type\": \"User\",\n            \"login\": participant.username\n        },\n        \"twitter\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://twitter.com/\" + participant.username,\n            \"screen_name\": participant.username\n        },\n        \"bitbucket\": {\n            \"display_name\": participant.username,\n            \"username\": participant.username,\n            \"is_team\": \"False\",\n            \"html_url\": \"https://bitbucket.org/\" + participant.username,\n        }\n    }\n\n    _fake_thing( db\n               , \"elsewhere\"\n               , id=fake_int_id()\n               , platform=platform\n               , user_id=fake_text_id()\n               , is_locked=False\n               , participant=participant.username\n               , user_info=info_templates[platform]\n                )\n\ndef fake_transfer(db, tipper, tippee):\n        return _fake_thing( db\n               , \"transfers\"\n               , id=fake_int_id()\n               , timestamp=faker.dateTimeThisYear()\n               , tipper=tipper.username\n               , tippee=tippee.username\n               , amount=fake_tip_amount()\n                )\n\n\ndef populate_db(db, num_participants=300, num_tips=200, num_teams=5, num_transfers=300):\n    \"\"\"Populate DB with fake data.\n    \"\"\"\n    #Make the participants\n    participants = []\n    for i in xrange(num_participants):\n        participants.append(fake_participant(db))\n\n    #Make the \"Elsewhere's\"\n    for p in participants:\n        #All participants get between 1 and 3 elsewheres\n        num_elsewheres = random.randint(1, 3)\n        for platform_name in platforms[:num_elsewheres]:\n            fake_elsewhere(db, p, platform_name)\n\n    #Make teams\n    for i in xrange(num_teams):\n        t = fake_participant(db, number=\"plural\")\n        #Add 1 to 3 members to the team\n        members = random.sample(participants, random.randint(1, 3))\n        for p in members:\n            t.add_member(p)\n\n    #Make the tips\n    tips = []\n    for i in xrange(num_tips):\n        tipper, tippee = random.sample(participants, 2)\n        tips.append(fake_tip(db, tipper, tippee))\n\n\n    #Make the transfers\n    transfers = []\n    for i in xrange(num_tips):\n        tipper, tippee = random.sample(participants, 2)\n        transfers.append(fake_transfer(db, tipper, tippee))\n\n\n    #Make some paydays\n    #First determine the boundaries - min and max date\n    min_date = min(min(x['ctime'] for x in tips), \\\n                   min(x['timestamp'] for x in transfers))\n    max_date = max(max(x['ctime'] for x in tips), \\\n                   max(x['timestamp'] for x in transfers))\n    #iterate through min_date, max_date one week at a time\n    date = min_date\n    while date < max_date:\n        end_date = date + datetime.timedelta(days=7)\n        week_tips = filter(lambda x: date <= x['ctime'] <= end_date, tips)\n        week_transfers = filter(lambda x: date <= x['timestamp'] <= end_date, transfers)\n        week_participants = filter(lambda x: x.ctime.replace(tzinfo=None) <= end_date, participants)\n        actives=set()\n        tippers=set()\n        for xfers in week_tips, week_transfers:\n            actives.update(x['tipper'] for x in xfers)\n            actives.update(x['tippee'] for x in xfers)\n            tippers.update(x['tipper'] for x in xfers)\n        payday = {\n            'id': fake_int_id(),\n            'ts_start': date,\n            'ts_end': end_date,\n            'ntips': len(week_tips),\n            'ntransfers': len(week_transfers),\n            'nparticipants': len(week_participants),\n            'ntippers': len(tippers),\n            'nactive': len(actives),\n            'transfer_volume': sum(x['amount'] for x in week_transfers)\n        }\n        #Make ach_volume and charge_volume between 0 and 10% of transfer volume\n        def rand_part():\n            return decimal.Decimal(random.random()* 0.1)\n        payday['ach_volume']   = -1 * payday['transfer_volume'] * rand_part()\n        payday['charge_volume'] = payday['transfer_volume'] * rand_part()\n        _fake_thing(db, \"paydays\", **payday)\n        date = end_date\n\n\n\ndef main():\n    populate_db(wireup.db())\n\nif __name__ == '__main__':\n    main()\n", "path": "gittip/utils/fake_data.py"}], "after_files": [{"content": "from faker import Factory\nfrom gittip import wireup, MAX_TIP, MIN_TIP\nfrom gittip.models.participant import Participant\n\nimport decimal\nimport random\nimport string\nimport datetime\n\n\nfaker = Factory.create()\n\nplatforms = ['github', 'twitter', 'bitbucket']\n\n\ndef _fake_thing(db, tablename, **kw):\n    column_names = []\n    column_value_placeholders = []\n    column_values = []\n\n    for k,v in kw.items():\n        column_names.append(k)\n        column_value_placeholders.append(\"%s\")\n        column_values.append(v)\n\n    column_names = \", \".join(column_names)\n    column_value_placeholders = \", \".join(column_value_placeholders)\n\n    db.run( \"INSERT INTO {} ({}) VALUES ({})\"\n            .format(tablename, column_names, column_value_placeholders)\n          , column_values\n           )\n    return kw\n\n\ndef fake_text_id(size=6, chars=string.ascii_lowercase + string.digits):\n    \"\"\"Create a random text id.\n    \"\"\"\n    return ''.join(random.choice(chars) for x in range(size))\n\n\ndef fake_balance(max_amount=100):\n    \"\"\"Return a random amount between 0 and max_amount.\n    \"\"\"\n    return random.random() * max_amount\n\n\ndef fake_int_id(nmax=2 ** 31 -1):\n    \"\"\"Create a random int id.\n    \"\"\"\n    return random.randint(0, nmax)\n\n\ndef fake_sentence(start=1, stop=100):\n    \"\"\"Create a sentence of random length.\n    \"\"\"\n    return faker.sentence(random.randrange(start,stop))\n\n\ndef fake_participant(db, number=\"singular\", is_admin=False, anonymous=False):\n    \"\"\"Create a fake User.\n    \"\"\"\n    username = faker.firstName() + fake_text_id(3)\n    d = _fake_thing( db\n               , \"participants\"\n               , id=fake_int_id()\n               , username=username\n               , username_lower=username.lower()\n               , statement=fake_sentence()\n               , ctime=faker.dateTimeThisYear()\n               , is_admin=is_admin\n               , balance=fake_balance()\n               , anonymous=anonymous\n               , goal=fake_balance()\n               , balanced_account_uri=faker.uri()\n               , last_ach_result=''\n               , is_suspicious=False\n               , last_bill_result=''  # Needed to not be suspicious\n               , claimed_time=faker.dateTimeThisYear()\n               , number=number\n                )\n    #Call participant constructor to perform other DB initialization\n    return Participant.from_username(username)\n\n\n\ndef fake_tip_amount():\n    amount = ((decimal.Decimal(random.random()) * (MAX_TIP - MIN_TIP))\n            + MIN_TIP)\n\n    decimal_amount = decimal.Decimal(amount).quantize(decimal.Decimal('.01'))\n\n    return decimal_amount\n\n\ndef fake_tip(db, tipper, tippee):\n    \"\"\"Create a fake tip.\n    \"\"\"\n    return _fake_thing( db\n               , \"tips\"\n               , id=fake_int_id()\n               , ctime=faker.dateTimeThisYear()\n               , mtime=faker.dateTimeThisMonth()\n               , tipper=tipper.username\n               , tippee=tippee.username\n               , amount=fake_tip_amount()\n                )\n\n\ndef fake_elsewhere(db, participant, platform=None):\n    \"\"\"Create a fake elsewhere.\n    \"\"\"\n    if platform is None:\n        platform = random.choice(platforms)\n\n    info_templates = {\n        \"github\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://github.com/\" + participant.username,\n            \"type\": \"User\",\n            \"login\": participant.username\n        },\n        \"twitter\": {\n            \"name\": participant.username,\n            \"html_url\": \"https://twitter.com/\" + participant.username,\n            \"screen_name\": participant.username\n        },\n        \"bitbucket\": {\n            \"display_name\": participant.username,\n            \"username\": participant.username,\n            \"is_team\": \"False\",\n            \"html_url\": \"https://bitbucket.org/\" + participant.username,\n        }\n    }\n\n    _fake_thing( db\n               , \"elsewhere\"\n               , id=fake_int_id()\n               , platform=platform\n               , user_id=fake_text_id()\n               , is_locked=False\n               , participant=participant.username\n               , user_info=info_templates[platform]\n                )\n\ndef fake_transfer(db, tipper, tippee):\n        return _fake_thing( db\n               , \"transfers\"\n               , id=fake_int_id()\n               , timestamp=faker.dateTimeThisYear()\n               , tipper=tipper.username\n               , tippee=tippee.username\n               , amount=fake_tip_amount()\n                )\n\n\ndef populate_db(db, num_participants=100, num_tips=200, num_teams=5, num_transfers=5000):\n    \"\"\"Populate DB with fake data.\n    \"\"\"\n    #Make the participants\n    participants = []\n    for i in xrange(num_participants):\n        participants.append(fake_participant(db))\n\n    #Make the \"Elsewhere's\"\n    for p in participants:\n        #All participants get between 1 and 3 elsewheres\n        num_elsewheres = random.randint(1, 3)\n        for platform_name in platforms[:num_elsewheres]:\n            fake_elsewhere(db, p, platform_name)\n\n    #Make teams\n    for i in xrange(num_teams):\n        t = fake_participant(db, number=\"plural\")\n        #Add 1 to 3 members to the team\n        members = random.sample(participants, random.randint(1, 3))\n        for p in members:\n            t.add_member(p)\n\n    #Make the tips\n    tips = []\n    for i in xrange(num_tips):\n        tipper, tippee = random.sample(participants, 2)\n        tips.append(fake_tip(db, tipper, tippee))\n\n\n    #Make the transfers\n    transfers = []\n    for i in xrange(num_transfers):\n        tipper, tippee = random.sample(participants, 2)\n        transfers.append(fake_transfer(db, tipper, tippee))\n\n\n    #Make some paydays\n    #First determine the boundaries - min and max date\n    min_date = min(min(x['ctime'] for x in tips), \\\n                   min(x['timestamp'] for x in transfers))\n    max_date = max(max(x['ctime'] for x in tips), \\\n                   max(x['timestamp'] for x in transfers))\n    #iterate through min_date, max_date one week at a time\n    date = min_date\n    while date < max_date:\n        end_date = date + datetime.timedelta(days=7)\n        week_tips = filter(lambda x: date <= x['ctime'] <= end_date, tips)\n        week_transfers = filter(lambda x: date <= x['timestamp'] <= end_date, transfers)\n        week_participants = filter(lambda x: x.ctime.replace(tzinfo=None) <= end_date, participants)\n        actives=set()\n        tippers=set()\n        for xfers in week_tips, week_transfers:\n            actives.update(x['tipper'] for x in xfers)\n            actives.update(x['tippee'] for x in xfers)\n            tippers.update(x['tipper'] for x in xfers)\n        payday = {\n            'id': fake_int_id(),\n            'ts_start': date,\n            'ts_end': end_date,\n            'ntips': len(week_tips),\n            'ntransfers': len(week_transfers),\n            'nparticipants': len(week_participants),\n            'ntippers': len(tippers),\n            'nactive': len(actives),\n            'transfer_volume': sum(x['amount'] for x in week_transfers)\n        }\n        #Make ach_volume and charge_volume between 0 and 10% of transfer volume\n        def rand_part():\n            return decimal.Decimal(random.random()* 0.1)\n        payday['ach_volume']   = -1 * payday['transfer_volume'] * rand_part()\n        payday['charge_volume'] = payday['transfer_volume'] * rand_part()\n        _fake_thing(db, \"paydays\", **payday)\n        date = end_date\n\n\n\ndef main():\n    populate_db(wireup.db())\n\nif __name__ == '__main__':\n    main()\n", "path": "gittip/utils/fake_data.py"}]}