Class: Wiq::Commands::Rosters

Inherits:
Base
  • Object
show all
Defined in:
lib/wiq/commands/rosters.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/wiq/commands/rosters.rb', line 35

def list
  params = { "per_page" => 100 }
  unless options[:archived].nil?
    params["q[archived_eq]"] = options[:archived]
  end
  params["q[location_id_eq]"] = options[:location] if options[:location]

  records, total = fetch_index("/api/v1/rosters", params, key: "rosters")

  if options[:season]
    resolver = Wiq::SeasonResolver.new(client)
    ids = resolver.paid_session_ids_for(options[:season])
    raise Wiq::SeasonNotFoundError, options[:season] if ids.empty?

    records = resolver.filter_rosters_by_ids(records, ids)
  end

  if options[:season_tag]
    tag = options[:season_tag]
    records = records.select do |r|
      (r["taggings"] || []).any? { |t| t.dig("tag", "name") == tag }
    end
  end

  render_index(
    records, total: total,
    summary: "Listed #{records.size} rosters.",
    breadcrumbs: [
      { "cmd" => "wiq rosters show <id>", "description" => "Inspect a single roster" },
      { "cmd" => "wiq reports run RosterReport --roster <id>",
        "description" => "Export the roster as a report" }
    ]
  )
end

#show(id) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/wiq/commands/rosters.rb', line 76

def show(id)
  roster = client.get("/api/v1/rosters/#{id}")
  render(roster,
         summary: "Roster #{roster["id"]}#{roster["name"]}",
         breadcrumbs: [
           { "cmd" => "wiq reports run RosterStatsReport --roster #{roster["id"]} --start <date> --end <date>",
             "description" => "Pull stats for this roster" },
           { "cmd" => "wiq check_ins summary --roster #{roster["id"]} --start <date> --end <date>",
             "description" => "Attendance summary for this roster" }
         ])
end