@@ -5,40 +5,70 @@ class ReportsController < ApplicationController
55 def index ; end
66
77 def features
8- data = Reports ::FeatureReportService . report
8+ forms = Reports ::FormDocumentsService . live_form_documents
9+ data = Reports ::FeatureReportService . new ( forms ) . report
910
1011 render template : "reports/features" , locals : { data : }
1112 end
1213
1314 def questions_with_answer_type
1415 answer_type = params . require ( :answer_type )
15- questions = Reports ::FeatureReportService . questions_with_answer_type ( answer_type )
16+ forms = Reports ::FormDocumentsService . live_form_documents
17+ questions = Reports ::FeatureReportService . new ( forms ) . questions_with_answer_type ( answer_type )
1618
1719 render template : "reports/questions_with_answer_type" , locals : { answer_type :, questions : }
1820 end
1921
2022 def questions_with_add_another_answer
21- questions = Reports ::FeatureReportService . live_questions_with_add_another_answer
23+ forms = Reports ::FormDocumentsService . live_form_documents
24+ questions = Reports ::FeatureReportService . new ( forms ) . questions_with_add_another_answer
2225
23- render template : "reports/questions_with_add_another_answer" , locals : { questions : }
26+ if params [ :format ] == "csv"
27+ send_data Reports ::QuestionsCsvReportService . new ( questions ) . csv ,
28+ type : "text/csv; charset=iso-8859-1" ,
29+ disposition : "attachment; filename=#{ csv_filename ( 'live_questions_with_add_another_answer_report' ) } "
30+ else
31+ render template : "reports/feature_report" , locals : { report : params [ :action ] , records : questions }
32+ end
2433 end
2534
2635 def forms_with_routes
27- forms = Reports ::FeatureReportService . live_forms_with_routes
36+ forms = Reports ::FormDocumentsService . live_form_documents
37+ forms = Reports ::FeatureReportService . new ( forms ) . forms_with_routes
2838
29- render template : "reports/forms_with_routes" , locals : { forms : forms }
39+ if params [ :format ] == "csv"
40+ send_data Reports ::FormsCsvReportService . new ( forms ) . csv ,
41+ type : "text/csv; charset=iso-8859-1" ,
42+ disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_routes_report' ) } "
43+ else
44+ render template : "reports/feature_report" , locals : { report : params [ :action ] , records : forms }
45+ end
3046 end
3147
3248 def forms_with_payments
33- forms = Reports ::FeatureReportService . live_forms_with_payments
49+ forms = Reports ::FormDocumentsService . live_form_documents
50+ forms = Reports ::FeatureReportService . new ( forms ) . forms_with_payments
3451
35- render template : "reports/forms_with_payments" , locals : { forms : forms }
52+ if params [ :format ] == "csv"
53+ send_data Reports ::FormsCsvReportService . new ( forms ) . csv ,
54+ type : "text/csv; charset=iso-8859-1" ,
55+ disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_payments_report' ) } "
56+ else
57+ render template : "reports/feature_report" , locals : { report : params [ :action ] , records : forms }
58+ end
3659 end
3760
3861 def forms_with_csv_submission_enabled
39- forms = Reports ::FeatureReportService . live_forms_with_csv_submission_enabled
62+ forms = Reports ::FormDocumentsService . live_form_documents
63+ forms = Reports ::FeatureReportService . new ( forms ) . forms_with_csv_submission_enabled
4064
41- render template : "reports/forms_with_csv_submission_enabled" , locals : { forms : forms }
65+ if params [ :format ] == "csv"
66+ send_data Reports ::FormsCsvReportService . new ( forms ) . csv ,
67+ type : "text/csv; charset=iso-8859-1" ,
68+ disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_csv_submission_enabled_report' ) } "
69+ else
70+ render template : "reports/feature_report" , locals : { report : params [ :action ] , records : forms }
71+ end
4272 end
4373
4474 def users
@@ -82,42 +112,27 @@ def selection_questions_with_checkboxes
82112 def csv_downloads ; end
83113
84114 def live_forms_csv
85- send_data Reports ::CsvReportsService . new . live_forms_csv ,
86- type : "text/csv; charset=iso-8859-1" ,
87- disposition : "attachment; filename=#{ csv_filename ( 'live_forms_report' ) } "
88- end
115+ forms = Reports ::FormDocumentsService . live_form_documents
89116
90- def live_forms_with_routes_csv
91- send_data Reports ::CsvReportsService . new . live_forms_with_routes_csv ,
117+ send_data Reports ::FormsCsvReportService . new ( forms ) . csv ,
92118 type : "text/csv; charset=iso-8859-1" ,
93- disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_routes_report' ) } "
94- end
95-
96- def live_forms_with_payments_csv
97- send_data Reports ::CsvReportsService . new . live_forms_with_payments_csv ,
98- type : "text/csv; charset=iso-8859-1" ,
99- disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_payments_report' ) } "
100- end
101-
102- def live_forms_with_csv_submission_enabled_csv
103- send_data Reports ::CsvReportsService . new . live_forms_with_csv_submission_enabled_csv ,
104- type : "text/csv; charset=iso-8859-1" ,
105- disposition : "attachment; filename=#{ csv_filename ( 'live_forms_with_csv_submission_enabled_report' ) } "
119+ disposition : "attachment; filename=#{ csv_filename ( 'live_forms_report' ) } "
106120 end
107121
108122 def live_questions_csv
109123 answer_type = params [ :answer_type ]
110- send_data Reports ::CsvReportsService . new . live_questions_csv ( answer_type :) ,
124+ forms = Reports ::FormDocumentsService . live_form_documents
125+ questions = if answer_type
126+ Reports ::FeatureReportService . new ( forms ) . questions_with_answer_type ( answer_type )
127+ else
128+ Reports ::FeatureReportService . new ( forms ) . questions
129+ end
130+
131+ send_data Reports ::QuestionsCsvReportService . new ( questions ) . csv ,
111132 type : "text/csv; charset=iso-8859-1" ,
112133 disposition : "attachment; filename=#{ questions_csv_filename ( answer_type ) } "
113134 end
114135
115- def live_questions_with_add_another_answer_csv
116- send_data Reports ::CsvReportsService . new . live_questions_with_add_another_answer_csv ,
117- type : "text/csv; charset=iso-8859-1" ,
118- disposition : "attachment; filename=#{ csv_filename ( 'live_questions_with_add_another_answer_report' ) } "
119- end
120-
121136private
122137
123138 def check_user_has_permission
0 commit comments