@@ -187,19 +187,19 @@ def build_csv_data
187187 yield [ 'user_info' ]
188188 yield USER_DATA_ATTRIBUTES
189189 yield USER_DATA_ATTRIBUTES . map { |attribute | send ( attribute . to_sym ) }
190- Group . build_csv_rows ( groups ) . each { |row | yield row }
191- GroupMember . build_csv_rows ( group_members ) . each { |row | yield row }
192- Category . build_csv_rows ( categories ) . each { |row | yield row }
193- Medication . build_csv_rows ( medications ) . each { |row | yield row }
194- Strategy . build_csv_rows ( strategies ) . each { |row | yield row }
195- Moment . build_csv_rows ( moments ) . each { |row | yield row }
196- Notification . build_csv_rows ( notifications ) . each { |row | yield row }
197- Mood . build_csv_rows ( moods ) . each { |row | yield row }
198- CarePlanContact . build_csv_rows ( care_plan_contacts ) . each { |row | yield row }
199- Allyship . build_csv_rows ( allyships ) . each { |row | yield row }
200- MeetingMember . build_csv_rows ( meeting_members ) . each { |row | yield row }
201- build_comment_csv_data . each { |row | yield row }
202- build_led_group_meeting_csv_data . each { |row | yield row }
190+ Group . build_csv_rows ( groups ) { |row | yield row }
191+ GroupMember . build_csv_rows ( group_members ) { |row | yield row }
192+ Category . build_csv_rows ( categories ) { |row | yield row }
193+ Medication . build_csv_rows ( medications ) { |row | yield row }
194+ Strategy . build_csv_rows ( strategies ) { |row | yield row }
195+ Moment . build_csv_rows ( moments ) { |row | yield row }
196+ Notification . build_csv_rows ( notifications ) { |row | yield row }
197+ Mood . build_csv_rows ( moods ) { |row | yield row }
198+ CarePlanContact . build_csv_rows ( care_plan_contacts ) { |row | yield row }
199+ Allyship . build_csv_rows ( allyships ) { |row | yield row }
200+ MeetingMember . build_csv_rows ( meeting_members ) { |row | yield row }
201+ build_comment_csv_data { |row | yield row }
202+ build_led_group_meeting_csv_data { |row | yield row }
203203 end
204204
205205 def generate_data_request
@@ -250,28 +250,25 @@ def delete_stale_data_file
250250 private
251251
252252 def build_comment_csv_data
253- moment_ids = moments . map ( &:id )
254- strategy_ids = strategies . map ( &:id )
255- data = [ ]
256- data += Comment . build_csv_rows (
253+ moment_ids = Moment . where ( user_id : id ) . pluck ( :id )
254+ strategy_ids = Strategy . where ( user_id : id ) . pluck ( :id )
255+ Comment . build_csv_rows (
257256 Comment . where ( commentable_type : 'Moment' , commentable_id : moment_ids )
258- )
259- data += Comment . build_csv_rows (
257+ ) { | row | yield row }
258+ Comment . build_csv_rows (
260259 Comment . where ( commentable_type : 'Strategy' , commentable_id : strategy_ids )
261- )
262- data
260+ ) { |row | yield row }
263261 end
264262
265263 def build_led_group_meeting_csv_data
266- leader_group_ids = group_members . where ( leader : true ) . pluck ( :group_id )
267- return [ ] if leader_group_ids . empty?
264+ leader_group_ids = GroupMember . where ( user_id : id , leader : true ) . pluck ( :group_id )
265+ return if leader_group_ids . empty?
268266
269267 leader_meetings = Meeting . where ( group_id : leader_group_ids )
270- data = Meeting . build_csv_rows ( leader_meetings )
271- data += Comment . build_csv_rows (
268+ Meeting . build_csv_rows ( leader_meetings ) { | row | yield row }
269+ Comment . build_csv_rows (
272270 Comment . where ( commentable_type : 'Meeting' , commentable_id : leader_meetings . pluck ( :id ) )
273- )
274- data
271+ ) { |row | yield row }
275272 end
276273
277274 def oauth_provided?
0 commit comments