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



28
29
30
31
32
33
34
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
# File 'lib/wiq/commands/rosters.rb', line 28

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

  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



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/wiq/commands/rosters.rb', line 68

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