Skip to content

Commit 390425c

Browse files
authored
Merge pull request #27 from biojs/develop
Visualizations serializer in details
2 parents a6d12fa + 87ceed6 commit 390425c

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

main/management/commands/updatecomponents.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ def handle(self, *args, **options):
242242
# update_visualizations(_component, latest_commit_hash)
243243
# else:
244244
_component.github_update_time = aware_date
245-
latest_commit_hash = get_commit_hash(github_data['commits_url'])
245+
try:
246+
latest_commit_hash = get_commit_hash(github_data['commits_url'])
247+
except:
248+
continue
246249
_component.latest_commit_hash = latest_commit_hash
247250
update_visualizations(_component, latest_commit_hash)
248251
# except:
@@ -255,19 +258,23 @@ def handle(self, *args, **options):
255258
continue
256259
commits = 0
257260
count = 0
258-
for contributor in contributors_data:
259-
try:
260-
_contributor = Contributor.objects.get(username=contributor["login"])
261-
except:
262-
_contributor = Contributor.objects.create(username=contributor["login"], avatar_url=contributor["avatar_url"])
263-
try:
264-
_contribution = Contribution.objects.get(component=_component, contributor=_contributor)
265-
_contribution.contributions = contributor["contributions"]
266-
_contribution.save()
267-
except:
268-
_contribution = Contribution.objects.create(component=_component, contributor=_contributor, contributions=contributor["contributions"])
269-
commits += _contribution.contributions
270-
count +=1
261+
try:
262+
for contributor in contributors_data:
263+
try:
264+
_contributor = Contributor.objects.get(username=contributor["login"])
265+
except:
266+
_contributor = Contributor.objects.create(username=contributor["login"], avatar_url=contributor["avatar_url"])
267+
try:
268+
_contribution = Contribution.objects.get(component=_component, contributor=_contributor)
269+
_contribution.contributions = contributor["contributions"]
270+
_contribution.save()
271+
except:
272+
_contribution = Contribution.objects.create(component=_component, contributor=_contributor, contributions=contributor["contributions"])
273+
commits += _contribution.contributions
274+
count +=1
275+
except:
276+
print 'Error'
277+
continue
271278
try:
272279
_component.downloads = get_downloads(str(github_data['downloads_url']) + '?client_id=' + GITHUB_CLIENT_ID + '&client_secret=' + GITHUB_CLIENT_SECRET)
273280
except:

main/views.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,25 @@ def component_details(request, url_name):
3939
contributions = ContributionSerializer(component.contributions, many=True)
4040
js_dependencies = JSDependencySerializer(component.jsdependency_set.all(), many=True)
4141
css_dependencies = CSSDependencySerializer(component.cssdependency_set.all(), many=True)
42-
sniper_data = component.sniperdata
43-
sniper = SniperDataSerializer(sniper_data)
44-
snippets = SnippetSerializer(sniper_data.snippet_set.all(), many=True)
45-
return JsonResponse({
46-
'details' : details.data,
47-
'contributors' : contributions.data,
48-
'js_dependencies' : js_dependencies.data,
49-
'css_dependencies' : css_dependencies.data,
50-
'sniper_data' : sniper.data,
51-
'snippets' : snippets.data,
52-
})
42+
try:
43+
sniper_data = component.sniperdata
44+
sniper = SniperDataSerializer(sniper_data)
45+
snippets = SnippetSerializer(sniper_data.snippet_set.all(), many=True)
46+
return JsonResponse({
47+
'details' : details.data,
48+
'contributors' : contributions.data,
49+
'js_dependencies' : js_dependencies.data,
50+
'css_dependencies' : css_dependencies.data,
51+
'sniper_data' : sniper.data,
52+
'snippets' : snippets.data,
53+
})
54+
except:
55+
return JsonResponse({
56+
'details' : details.data,
57+
'contributors' : contributions.data,
58+
'js_dependencies' : js_dependencies.data,
59+
'css_dependencies' : css_dependencies.data,
60+
})
5361

5462
def render_visualization(request, url_name, visualization_name):
5563
component = Component.objects.get(url_name=url_name)

0 commit comments

Comments
 (0)