Skip to content

Instantly share code, notes, and snippets.

@sclinede
Last active October 16, 2015 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sclinede/f7df182c047086ff12a3 to your computer and use it in GitHub Desktop.
Save sclinede/f7df182c047086ff12a3 to your computer and use it in GitHub Desktop.
def filter_by_auths(joins)
return unless filtered_by_int?(:auths_in_curr_month_from) || filtered_by_int?(:auths_in_curr_month_to) ||
filtered_by_int?(:auths_in_prev_month_from) || filtered_by_int?(:auths_in_prev_month_to)
auth_join_conditions = {
:auths_in_curr_month_from => " AND #{COS}.visits_in_current_month >= %{val}",
:auths_in_curr_month_to => " AND #{COS}.visits_in_current_month <= %{val}",
:auths_in_prev_month_from => " AND #{COS}.visits_in_prev_month >= %{val}",
:auths_in_prev_month_to => " AND #{COS}.visits_in_prev_month <= %{val}"
}.map! do |filter, condition|
condition % {val: get_int_filter(filter)} if filtered_by_int?(filter)
end.compact!
joins << "JOIN #{COS} ON company_online_stats.company_id = companies.id " + auth_join_conditions.join(' ')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment