alphagov/EFG — pull request #83 by olly (2012-11-16 17:04:03+00:00)
Title: Re-factor Reports

This contains some re-factorings of the CSV exporters so they now all inherit from `BaseCsvExporter`. It also includes some major performance improvements for `LoanCsvExporter`.

Loan Report CSV Export
----------------------

report = LoanReport.new
report.loan_sources = LoanReport::ALLOWED_LOAN_SOURCES
report.states = Loan::States
report.lender_ids = Lender.pluck(:id)
export = LoanReportCsvExport.new(report.loans)
export.generate

dcd7edcffc6c451086eef6df578a48a4155a7c9b

28.320000 0.670000 28.990000 ( 30.888538)

fa4b4d1f1611680447946bf6b17122ac50cd596f

30.700000 0.590000 31.290000 ( 32.938233)

bda4a0d4805bfd57f3739b4574639d0c27f73531

28.870000 0.850000 29.720000 ( 31.365477)

1def4b93bfae0cff46707ce913fa7fd86e9cac63

28.460000 0.500000 28.960000 ( 30.567949)

187f003313180c55197c6dd20bd5d98f2e23fc1a

28.290000 0.520000 28.810000 ( 30.388084)

bdbcfb1e2cb2ca051eac82e519a90a9b93f67225

28.740000 0.730000 29.470000 ( 31.074019)

e7effadee3cdc325e693bf98f41659eba6f61643

28.290000 0.720000 29.010000 ( 30.602289)

07d601568d08ef65191324252635ab22bbfd96e6

29.590000 0.670000 30.260000 ( 31.874557)

33cc3c0f8dd4b7c223bfa13edbb6c781a2ff0e27

27.010000 0.470000 27.480000 ( 29.224203)

90b3c132ca635401c03edd4ca697481961c63ff6

25.700000 0.630000 26.330000 ( 28.141599)

75157d6da23dd0695e803a8fc8eb6d35fc857a3f

25.400000 0.740000 26.140000 ( 27.811775)

Loan CSV Export
---------------

loans = Loan.scoped.where('id < 2000')
export = LoanCsvExport.new(loans)
export.generate

187f003313180c55197c6dd20bd5d98f2e23fc1a

19.250000 0.820000 20.070000 ( 21.632414)

33cc3c0f8dd4b7c223bfa13edbb6c781a2ff0e27

19.080000 0.830000 19.910000 ( 21.352361)

90b3c132ca635401c03edd4ca697481961c63ff6

11.760000 0.370000 12.130000 ( 12.202587)

75157d6da23dd0695e803a8fc8eb6d35fc857a3f

5.630000 0.310000 5.940000 ( 6.016954)