diff --git a/app/controllers/api/v8/user_app_datum_controller.rb b/app/controllers/api/v8/user_app_datum_controller.rb index 52303c8a2..a1891e1b7 100644 --- a/app/controllers/api/v8/user_app_datum_controller.rb +++ b/app/controllers/api/v8/user_app_datum_controller.rb @@ -13,7 +13,28 @@ def index return render json: data end - render json: UserAppDatum.all + headers['X-Accel-Buffering'] = 'no' + headers['Cache-Control'] = 'no-cache' + headers['Content-Type'] = 'application/json' + # headers['Transfer-Encoding'] = 'chunked' + headers.delete('Content-Length') + + self.response_body = build_json_enumerator(UserAppDatum) + # render json: UserAppDatum.all + end + + private + def build_json_enumerator(query) + first = true + Enumerator.new do |yielder| + yielder << '[' + query.find_each do |datum| + yielder << ',' unless first + yielder << datum.to_json + first = false + end + yielder << ']' + end end end end