Skip to content

Commit

Permalink
Merge pull request #3194 from SEED-platform/fix/no-analyses-crash
Browse files Browse the repository at this point in the history
Fix/no analyses crash
  • Loading branch information
Ryo committed Mar 31, 2022
2 parents 8b36fa6 + 5eaf096 commit 8a57b54
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions seed/views/v3/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,24 @@ def list(self, request):
serialized_analysis.update({'highlights': analysis.get_highlights(property_id)})
analyses.append(serialized_analysis)

views_queryset = AnalysisPropertyView.objects.filter(analysis__organization_id=organization_id).order_by('-id')
serialized_views = []
property_views_by_apv_id = AnalysisPropertyView.get_property_views(views_queryset)
for view in views_queryset:
serialized_view = AnalysisPropertyViewSerializer(view).data
serialized_views.append(serialized_view)
original_views = {}
if analyses:
views_queryset = AnalysisPropertyView.objects.filter(analysis__organization_id=organization_id).order_by('-id')
property_views_by_apv_id = AnalysisPropertyView.get_property_views(views_queryset)
for view in views_queryset:
serialized_view = AnalysisPropertyViewSerializer(view).data
serialized_views.append(serialized_view)
original_views = {
apv_id: property_view.id if property_view is not None else None
for apv_id, property_view in property_views_by_apv_id.items()
}

return JsonResponse({
'status': 'success',
'analyses': analyses,
'views': serialized_views,
'original_views': {
apv_id: property_view.id if property_view is not None else None
for apv_id, property_view in property_views_by_apv_id.items()
}
'original_views': original_views
})

@swagger_auto_schema(manual_parameters=[AutoSchemaHelper.query_org_id_field(True)])
Expand Down

0 comments on commit 8a57b54

Please sign in to comment.