Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from tuulos/master

Handle empty profiles
  • Loading branch information...
commit 4fc901f700b7549cd613c407a1d30caa2befc980 2 parents 59d71e8 + 32a1283
@tuulos tuulos authored
Showing with 26 additions and 15 deletions.
  1. +26 −15 __main__.py
View
41 __main__.py
@@ -43,21 +43,32 @@ def popularity(repos):
for profile in profiles:
for repo, visits in profile['repos'].iteritems():
repos[repo].update(frozenset(recent_days(visits)))
-
- pop = list(popularity(repos))
- text['popular'] = max(pop)
- text['total'] = sum(visits for visits, repo in pop)
-
- yield {'type': 'text',
- 'size': (12, 1),
- 'head': 'Daily Unique Visitors'}
-
- for repo, stats in sorted(repos.iteritems()):
- yield {'type': 'line',
- 'label': repo.split('/')[1],
- 'data': list(timeline(stats)),
- 'size': (6, 2)}
-
+
+ if repos:
+ pop = list(popularity(repos))
+ text['popular'] = max(pop)
+ text['total'] = sum(visits for visits, repo in pop)
+
+ yield {'type': 'text',
+ 'size': (12, 1),
+ 'head': 'Daily Unique Visitors'}
+
+ for repo, stats in sorted(repos.iteritems()):
+ yield {'type': 'line',
+ 'label': repo.split('/')[1],
+ 'data': list(timeline(stats)),
+ 'size': (6, 2)}
+ else:
+ yield {'type': 'text',
+ 'size': (12, 1),
+ 'color': 3,
+ 'head': 'Bummer! No data yet'}
+ yield {'type': 'text',
+ 'size': (12, 2),
+ 'text': """It may take an hour for the first
+ visits to appear after you have added the badge
+ for the first time."""}
+
Profiles().map(activity).show()
Profiles().map(countries).show('map',
Please sign in to comment.
Something went wrong with that request. Please try again.