Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle empty profiles #1

Merged
merged 1 commit into from

1 participant

Ville Tuulos
Ville Tuulos
Owner

No description provided.

Ville Tuulos tuulos merged commit 4fc901f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2013
  1. Ville Tuulos Bitdeli

    handle empty profiles

    tuulos authored bitdeli-commits committed
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 15 deletions.
  1. +26 −15 __main__.py
41 __main__.py
View
@@ -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',
Something went wrong with that request. Please try again.