Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change the simple image output mode to not use full image objects,

and instead use .values() to get the data directly, then spit it
out in a dict to have it consumed by the json serializer.
  • Loading branch information...
commit dc03c4d52c44a84733ca394ddb0a00ec0a6a2855 1 parent bb496cd
Christopher Schmidt crschmidt authored

Showing 1 changed file with 17 additions and 5 deletions. Show diff stats Hide diff stats

  1. +17 5 imageryindex/django/oamcatalog/main/views.py
22 imageryindex/django/oamcatalog/main/views.py
@@ -132,11 +132,23 @@ def handle_update(request, image):
132 132 limit = min(int(request.GET.get("limit", 1000)), 10000)
133 133 start = int(request.GET.get("start", 0))
134 134 end = start + limit
135   - images = images.order_by("-id")
136   - data = {'images': [
137   - i.to_json(output=output) for i in images[start:end]
138   - ]
139   - }
  135 + images = images.order_by("-id")
  136 +
  137 + # Instantiating full image objects for thousands of images is slow;
  138 + # instead, just use .values and make our own dict here. Adding more
  139 + # properties here should be done with consideration.
  140 + if output == 'simple':
  141 + data = {'images':
  142 + [dict(x) for x in images[start:end].values("id", "width", "height", "url", "bbox")]
  143 + }
  144 + for i in data['images']:
  145 + i['bbox'] = list(i['bbox'].extent)
  146 +
  147 + else:
  148 + data = {'images': [
  149 + i.to_json(output=output) for i in images[start:end]
  150 + ]
  151 + }
140 152 return json_response(request, data)
141 153
142 154 def home(request):

0 comments on commit dc03c4d

Please sign in to comment.
Something went wrong with that request. Please try again.