Skip to content

Commit

Permalink
Clean up Ruby code with Rufo
Browse files Browse the repository at this point in the history
  • Loading branch information
sman591 committed May 29, 2019
1 parent 8b87043 commit b345d23
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
3 changes: 0 additions & 3 deletions app/datatables/admin_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def data
end
end

# rubocop:disable Naming/AccessorMethodName
def get_raw_records
User.where(role: [:admin, :admin_limited_access, :event_tracking])
end

# rubocop:enable Naming/AccessorMethodName
end
12 changes: 5 additions & 7 deletions app/datatables/bulk_message_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def view_columns
subject: { source: "Message.subject" },
created_at: { source: "Message.created_at", searchable: false },
updated_at: { source: "Message.updated_at", searchable: false },
delivered_at: { source: "Message.delivered_at", searchable: false }
delivered_at: { source: "Message.delivered_at", searchable: false },
}
end

Expand All @@ -20,17 +20,15 @@ def data
id: record.id,
name: link_to(bold(record.name), manage_message_path(record)),
subject: record.subject,
status: record.status == 'drafted' ? "<span style=\"color: red;\">#{h(record.status.titleize)}</span>".html_safe : record.status.titleize,
status: record.status == "drafted" ? "<span style=\"color: red;\">#{h(record.status.titleize)}</span>".html_safe : record.status.titleize,
created_at: display_datetime(record.created_at),
updated_at: record.updated_at.present? ? display_datetime(record.updated_at) : '',
delivered_at: record.delivered_at.present? ? display_datetime(record.delivered_at) : ''
updated_at: record.updated_at.present? ? display_datetime(record.updated_at) : "",
delivered_at: record.delivered_at.present? ? display_datetime(record.delivered_at) : "",
}
end
end

# rubocop:disable Naming/AccessorMethodName
def get_raw_records
Message.where(type: 'bulk')
Message.where(type: "bulk")
end
# rubocop:enable Naming/AccessorMethodName
end
18 changes: 8 additions & 10 deletions app/datatables/checkin_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ class CheckinDatatable < AjaxDatatablesRails::Base

def view_columns
@view_columns ||= {
first_name: { source: 'Questionnaire.first_name' },
last_name: { source: 'Questionnaire.last_name' },
checked_in: { source: 'Questionnaire.checked_in_at', searchable: false },
first_name: { source: "Questionnaire.first_name" },
last_name: { source: "Questionnaire.last_name" },
checked_in: { source: "Questionnaire.checked_in_at", searchable: false },
}
end

private

def about(record)
output = ''
output += [record.first_name, record.last_name].join(' ') + ' '
output = ""
output += [record.first_name, record.last_name].join(" ") + " "
output += '<span class="badge badge-warning"><i class="fa fa-exclamation-triangle icon-space-r"></i>Minor</span>' if record.minor?
output += '<br /><small>' + record.school.name + '</small>'
output += "<br /><small>" + record.school.name + "</small>"
output.html_safe
end

Expand All @@ -25,15 +25,13 @@ def data
first_name: record.first_name,
last_name: record.last_name,
about: about(record),
checked_in: record.checked_in? ? "<span class=\"text-success\">Yes</span>".html_safe : 'No',
actions: "<a class=\"btn btn-primary btn-sm\" href=\"#{manage_checkin_path(record)}\">View</a>".html_safe
checked_in: record.checked_in? ? "<span class=\"text-success\">Yes</span>".html_safe : "No",
actions: "<a class=\"btn btn-primary btn-sm\" href=\"#{manage_checkin_path(record)}\">View</a>".html_safe,
}
end
end

# rubocop:disable Naming/AccessorMethodName
def get_raw_records
Questionnaire.includes(:user, :school).references(:user, :school)
end
# rubocop:enable Naming/AccessorMethodName
end
2 changes: 0 additions & 2 deletions app/datatables/questionnaire_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def data
end
end

# rubocop:disable Naming/AccessorMethodName
def get_raw_records
Questionnaire.includes(:user, :school).references(:user, :school)
end
# rubocop:enable Naming/AccessorMethodName
end
14 changes: 6 additions & 8 deletions app/datatables/school_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class SchoolDatatable < AjaxDatatablesRails::Base

def view_columns
@view_columns ||= {
id: { source: 'School.id', cond: :eq },
name: { source: 'School.name' },
city: { source: 'School.city' },
state: { source: 'School.state' },
questionnaire_count: { source: 'School.questionnaire_count', searchable: false }
id: { source: "School.id", cond: :eq },
name: { source: "School.name" },
city: { source: "School.city" },
state: { source: "School.state" },
questionnaire_count: { source: "School.questionnaire_count", searchable: false },
}
end

Expand All @@ -20,14 +20,12 @@ def data
name: link_to(bold(record.name), manage_school_path(record)),
city: record.city,
state: record.state,
questionnaire_count: record.questionnaire_count
questionnaire_count: record.questionnaire_count,
}
end
end

# rubocop:disable Naming/AccessorMethodName
def get_raw_records
School.all
end
# rubocop:enable Naming/AccessorMethodName
end

0 comments on commit b345d23

Please sign in to comment.