Class: Wiq::Commands::Wrestlers

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

Constant Summary collapse

PROFILE_TYPES =

Match WrestlerProfile constants in app/models/wrestler_profile.rb.

%w[teammate alumnus guest all].freeze
DEFAULT_PER_PAGE =
20

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/wiq/commands/wrestlers.rb', line 58

def list
  params = build_list_params

  records, total = fetch_index("/api/v1/wrestlers", params, key: "wrestlers")
  render_index(
    records, total: total,
    summary: "Listed #{records.size} wrestlers#{summary_filters_suffix}.",
    breadcrumbs: [
      { "cmd" => "wiq wrestlers show <id>", "description" => "Drill into one wrestler" },
      { "cmd" => "wiq check_ins wrestler <id>", "description" => "See a wrestler's check-in history" },
      { "cmd" => "wiq reports run RosterReport --roster 0 --append-properties <q_ids>",
        "description" => "For exhaustive exports, use a report instead" }
    ]
  )
end

#show(id) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/wiq/commands/wrestlers.rb', line 86

def show(id)
  params = {}
  params["expand_rosters"] = true if expand_includes?("rosters")
  params["expand_registration_answers"] = true if expand_includes?("registration_answers")
  wrestler = client.get("/api/v1/wrestlers/#{id}", params)
  render(wrestler,
         summary: "Wrestler #{wrestler["id"]}#{wrestler["full_name"] || wrestler["display_name"]}",
         breadcrumbs: [
           { "cmd" => "wiq check_ins wrestler #{wrestler["id"]}",
             "description" => "Check-in history for this wrestler" },
           { "cmd" => "wiq registrations answers --profile #{wrestler["id"]} --profile-type WrestlerProfile",
             "description" => "Registration answers (subject to visibility gating)" }
         ])
end