Skip to content

Commit

Permalink
Use options hash for to_csv
Browse files Browse the repository at this point in the history
  • Loading branch information
orien committed Feb 10, 2024
1 parent b1defbb commit c82d09f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/presenters/user_csv_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ class UserCsvPresenter
## - user_id - defaults to nil, reports on only one user (will set inherited to true)
## - datetime - defaults to now, Timestamp for when the report is kicked off and generated

def self.to_csv(
inherited: false, deleted: false, project_id: nil, user_id: nil, datetime: (Time.now.strftime "%Y%m%d_%H%M")
)
def self.to_csv(options = {})
inherited = options.fetch(:inherited, false)
deleted = options.fetch(:deleted, false)
project_id = options.fetch(:project_id, nil)
user_id = options.fetch(:user_id, nil)
datetime = options.fetch(:datetime, Time.now.strftime("%Y%m%d_%H%M"))

inherited = true if project_id || user_id
users = (deleted || user_id ? User.unscoped : User)
users = users.order(:id)
Expand Down

0 comments on commit c82d09f

Please sign in to comment.