@@ -19,32 +19,34 @@ def render?
1919 # asynchronous data, and vice versa. We therefore need to determine which fields
2020 # to render based on whether there is a value present or not
2121 def descriptions
22- @ descriptions = [
22+ descriptions = [
2323 contact_time ,
24- contact_email
24+ contact_email ,
25+ sync_data ,
26+ async_data
2527 ]
26- check_for_sync_data
27- check_for_async_data
28- @descriptions
28+ descriptions . flatten . compact
2929 end
3030
31- # rubocop:disable Metrics/AbcSize
32- def check_for_sync_data
33- @descriptions << webchat_sync if supplier . contact_webchat_sync
34- @descriptions << whatsapp_sync if supplier . contact_whatsapp_sync
35- @descriptions << sms_sync if supplier . contact_sms_sync
36- @descriptions << in_app_sync if supplier . contact_in_app_sync
37- @descriptions << portal_sync if supplier . contact_portal_sync
31+ def sync_data
32+ [
33+ webchat_sync ,
34+ whatsapp_sync ,
35+ sms_sync ,
36+ in_app_sync ,
37+ portal_sync
38+ ]
3839 end
3940
40- def check_for_async_data
41- @descriptions << webchat_async if supplier . contact_webchat_async
42- @descriptions << whatsapp_async if supplier . contact_whatsapp_async
43- @descriptions << sms_async if supplier . contact_sms_async
44- @descriptions << in_app_async if supplier . contact_in_app_async
45- @descriptions << portal_async if supplier . contact_portal_async
41+ def async_data
42+ [
43+ webchat_async ,
44+ whatsapp_async ,
45+ sms_async ,
46+ in_app_async ,
47+ portal_async
48+ ]
4649 end
47- # rubocop:enable Metrics/AbcSize
4850
4951 def contact_time
5052 {
@@ -70,69 +72,89 @@ def format_sync_output(time_str)
7072 end
7173
7274 def webchat_sync
75+ return unless supplier . contact_webchat_sync
76+
7377 {
7478 term : content_tag ( :p , "Average Webchat response time" ) ,
7579 description : content_tag ( :p , format_sync_output ( supplier . contact_webchat_sync ) )
7680 }
7781 end
7882
7983 def webchat_async
84+ return unless supplier . contact_webchat_async
85+
8086 {
8187 term : content_tag ( :p , "Webchat messages responded to within 2 days" ) ,
8288 description : content_tag ( :p , "#{ supplier . contact_webchat_async } %" )
8389 }
8490 end
8591
8692 def whatsapp_sync
93+ return unless supplier . contact_whatsapp_sync
94+
8795 {
8896 term : content_tag ( :p , "Average Whatsapp response time" ) ,
8997 description : content_tag ( :p , format_sync_output ( supplier . contact_whatsapp_sync ) )
9098 }
9199 end
92100
93101 def whatsapp_async
102+ return unless supplier . contact_whatsapp_async
103+
94104 {
95105 term : content_tag ( :p , "Whatsapp messages responded to within 2 days" ) ,
96106 description : content_tag ( :p , "#{ supplier . contact_whatsapp_async } %" )
97107 }
98108 end
99109
100110 def sms_sync
111+ return unless supplier . contact_sms_sync
112+
101113 {
102114 term : content_tag ( :p , "Average SMS response time" ) ,
103115 description : content_tag ( :p , format_sync_output ( supplier . contact_sms_sync ) )
104116 }
105117 end
106118
107119 def sms_async
120+ return unless supplier . contact_sms_async
121+
108122 {
109123 term : content_tag ( :p , "SMS messages responded to within 2 days" ) ,
110124 description : content_tag ( :p , "#{ supplier . contact_sms_async } %" )
111125 }
112126 end
113127
114128 def in_app_sync
129+ return unless supplier . contact_in_app_sync
130+
115131 {
116132 term : content_tag ( :p , "Average response time using the supplier's app" ) ,
117133 description : content_tag ( :p , format_sync_output ( supplier . contact_in_app_sync ) )
118134 }
119135 end
120136
121137 def in_app_async
138+ return unless supplier . contact_in_app_async
139+
122140 {
123141 term : content_tag ( :p , "Messages responded to within 2 days using the supplier's app" ) ,
124142 description : content_tag ( :p , "#{ supplier . contact_in_app_async } %" )
125143 }
126144 end
127145
128146 def portal_sync
147+ return unless supplier . contact_portal_sync
148+
129149 {
130150 term : content_tag ( :p , "Average response time using a customer account portal" ) ,
131151 description : content_tag ( :p , format_sync_output ( supplier . contact_portal_sync ) )
132152 }
133153 end
134154
135155 def portal_async
156+ return unless supplier . contact_portal_async
157+
136158 {
137159 term : content_tag ( :p , "Messages responded to within 2 days using a customer account portal" ) ,
138160 description : content_tag ( :p , "#{ supplier . contact_portal_async } %" )
0 commit comments