Browse Source

Remove count query from CSV download path (#714)

* Remove count query from CSV download path

* Rubocop

* Legit complete log

* Spec
pull/712/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
de9a86b3c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/controllers/case_logs_controller.rb
  2. 290
      spec/fixtures/complete_case_log.json

5
app/controllers/case_logs_controller.rb

@ -14,12 +14,13 @@ class CaseLogsController < ApplicationController
all_logs = current_user.case_logs all_logs = current_user.case_logs
unpaginated_filtered_logs = filtered_case_logs(filtered_collection(all_logs, search_term)) unpaginated_filtered_logs = filtered_case_logs(filtered_collection(all_logs, search_term))
respond_to do |format|
format.html do
@pagy, @case_logs = pagy(unpaginated_filtered_logs) @pagy, @case_logs = pagy(unpaginated_filtered_logs)
@searched = search_term.presence @searched = search_term.presence
@total_count = all_logs.size @total_count = all_logs.size
end
respond_to do |format|
format.html
format.csv do format.csv do
send_data unpaginated_filtered_logs.to_csv, filename: "logs-#{Time.zone.now}.csv" send_data unpaginated_filtered_logs.to_csv, filename: "logs-#{Time.zone.now}.csv"
end end

290
spec/fixtures/complete_case_log.json vendored

@ -1,138 +1,186 @@
{ {
"case_log": { "case_log": {
"tenancycode": "T657", "tenancycode":"T1245",
"age1": 35, "age1":34,
"sex1": "F", "sex1":"M",
"ethnic": 0, "ethnic":1,
"national": 0, "national":1,
"prevten": 6, "prevten":3,
"armedforces": 1,
"armed_forces_partner": "",
"ecstat1":1, "ecstat1":1,
"hhmemb": 8, "hhmemb":3,
"relat2": "P", "age2":29,
"age2": 32, "sex2":"F",
"sex2": "M", "ecstat2":2,
"ecstat2": 6, "age3":11,
"relat3": "C", "sex3":"R",
"age3": 12,
"sex3": "M",
"ecstat3":9, "ecstat3":9,
"relat4": "C", "age4":null,
"age4": 12, "sex4":null,
"sex4": "F", "ecstat4":null,
"ecstat4": 9, "age5":null,
"relat5": "C", "sex5":null,
"age5": 10, "ecstat5":null,
"sex5": "X", "age6":null,
"ecstat5": 9, "sex6":null,
"relat6": "C", "ecstat6":null,
"age6": 5, "age7":null,
"sex6": "R", "sex7":null,
"ecstat6": 9, "ecstat7":null,
"age7": 5, "age8":null,
"sex7": "R", "sex8":null,
"ecstat7": 9, "ecstat8":null,
"relat8": "C", "homeless":1,
"age8": 2, "underoccupation_benefitcap":2,
"sex8": "R", "leftreg":null,
"ecstat8": 9, "reservist":null,
"homeless": 2, "illness":2,
"reason": 1, "preg_occ":2,
"underoccupation_benefitcap": 0, "startertenancy":2,
"leftreg": 1, "tenancylength":null,
"reservist": 0, "tenancy":2,
"illness": 1, "ppostcode_full":"NW18TR",
"preg_occ": 1, "rsnvac":5,
"startdate": "12/12/2021",
"startertenancy": 0,
"tenancylength": 5,
"tenancy": 1,
"landlord": 1,
"previous_la_known": 1,
"la": "Barnet",
"postcode_full": "NW1 5TY",
"property_relet": 0,
"rsnvac": 14,
"property_reference": "P9876",
"unittype_gn":7, "unittype_gn":7,
"property_building_type": "dummy", "beds":2,
"beds": 3, "offered":0,
"voiddate": "10/10/2020",
"majorrepairs": 1,
"mrcdate": "11/11/2020",
"offered": 2,
"wchair":1, "wchair":1,
"net_income_known": 1, "earnings":190,
"earnings": 150,
"incfreq":1, "incfreq":1,
"benefits": 1, "benefits":3,
"hb": 1, "period":3,
"period": 2, "layear":7,
"brent": 200, "waityear":2,
"scharge": 50, "postcode_full":"NW18EE",
"pscharge": 40, "reasonpref":2,
"supcharg": 35, "cbl":1,
"tcharge": 325, "chr":0,
"outstanding_amount": 1,
"layear": 2,
"lawaitlist": 1,
"prevloc": "E07000105",
"ppostcode_full": "SE2 6RT",
"reasonpref": 1,
"cbl": 0,
"chr": 1,
"cap":0, "cap":0,
"hbrentshortfall": 1, "reasonother":"",
"tshortfall": 12, "housingneeds_a":0,
"reasonother": null,
"housingneeds_a": 1,
"housingneeds_b":0, "housingneeds_b":0,
"housingneeds_c": 0, "housingneeds_c":1,
"housingneeds_f":0, "housingneeds_f":0,
"housingneeds_g":0, "housingneeds_g":0,
"housingneeds_h":0, "housingneeds_h":0,
"accessibility_requirements_prefer_not_to_say": 0, "illness_type_1":null,
"illness_type_1": 0, "illness_type_2":null,
"illness_type_2": 1, "illness_type_3":null,
"illness_type_3": 0, "illness_type_4":null,
"illness_type_4": 0, "illness_type_8":null,
"illness_type_8": 0, "illness_type_5":null,
"illness_type_5": 0, "illness_type_6":null,
"illness_type_6": 0, "illness_type_7":null,
"illness_type_7": 0, "illness_type_9":null,
"illness_type_9": 0, "illness_type_10":null,
"illness_type_10": 0, "rp_homeless":null,
"condition_effects_prefer_not_to_say": 1, "rp_insan_unsat":null,
"rp_homeless": 0, "rp_medwel":null,
"rp_insan_unsat": 0, "rp_hardship":null,
"rp_medwel": 0, "rp_dontknow":null,
"rp_hardship": 0, "tenancyother":"",
"rp_dontknow": 0, "net_income_value_check":null,
"discarded_at": "05/05/2020", "property_owner_organisation":null,
"net_income_value_check": 0, "property_manager_organisation":null,
"property_owner_organisation": "", "sale_or_letting":null,
"property_manager_organisation": "", "irproduct_other":"",
"rent_type": 0, "purchaser_code":null,
"intermediate_rent_product_name": "", "reason":42,
"needstype": 1, "propcode":"PT562",
"sale_completion_date": "01/01/2020", "majorrepairs":1,
"purchaser_code": "", "la":"E09000007",
"propcode": "123", "prevloc":"E09000007",
"postcode": "a1", "hb":9,
"postcod2": "w3", "hbrentshortfall":null,
"property_relet":null,
"mrcdate":"2021-05-07T00:00:00.000+01:00",
"incref":null,
"sale_completion_date":null,
"startdate":"2021-06-06T00:00:00.000+01:00",
"armedforces":2,
"first_time_property_let_as_social_housing":0, "first_time_property_let_as_social_housing":0,
"unitletas":1, "unitletas":1,
"builtype": 0, "builtype":1,
"property_wheelchair_accessible": 1, "voiddate":"2021-05-05T00:00:00.000+01:00",
"void_or_renewal_date": "05/05/2020", "owning_organisation_id":1,
"renewal": 0, "managing_organisation_id":1,
"new_build_handover_date": "01/01/2019", "renttype":2,
"has_benefits": 1, "needstype":1,
"household_charge": 0, "lettype":7,
"is_carehome": 0, "postcode_known":1,
"sheltered": 0, "is_la_inferred":true,
"totchild":1,
"totelder":0,
"totadult":2,
"net_income_known":0,
"nocharge":0,
"is_carehome":null,
"household_charge":null,
"referral":2,
"brent":"350.0",
"scharge":"11.0",
"pscharge":"11.0",
"supcharg":"0.0",
"tcharge":"372.0",
"tshortfall":null,
"chcharge":null,
"declaration":1, "declaration":1,
"referral": 1 "ppcodenk":1,
"previous_la_known":null,
"is_previous_la_inferred":true,
"age1_known":0,
"age2_known":0,
"age3_known":0,
"age4_known":null,
"age5_known":null,
"age6_known":null,
"age7_known":null,
"age8_known":null,
"ethnic_group":0,
"ethnic_other":null,
"letting_allocation_unknown":0,
"details_known_2":0,
"details_known_3":0,
"details_known_4":null,
"details_known_5":null,
"details_known_6":null,
"details_known_7":null,
"details_known_8":null,
"rent_type":1,
"has_benefits":0,
"renewal":0,
"wrent":"87.5",
"wscharge":"2.75",
"wpschrge":"2.75",
"wsupchrg":"0.0",
"wtcharge":"93.0",
"wtshortfall":null,
"refused":1,
"housingneeds":2,
"wchchrg":null,
"newprop":2,
"relat2":"P",
"relat3":"C",
"relat4":null,
"relat5":null,
"relat6":null,
"relat7":null,
"relat8":null,
"rent_value_check":null,
"old_form_id":null,
"lar":null,
"irproduct":null,
"old_id":null,
"joint":null,
"created_by_id":2,
"illness_type_0":null,
"retirement_value_check":null,
"tshortfall_known":null,
"sheltered":null,
"pregnancy_value_check":null,
"hhtype":6,
"new_old":1,
"vacdays":30,
"scheme_id":null,
"location_id":null
} }
} }

Loading…
Cancel
Save