Class: Wiq::Commands::Events

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

Constant Summary collapse

TYPES =

Canonical event_type strings from app/models/event.rb. Surfaced via ‘wiq events types` so agents don’t have to guess.

{
  "practice" => "Practice events. The default for most clubs.",
  "dual_meet" => "Dual meet — match-style competition against one opposing team.",
  "tournament" => "Tournament — bracket-style competition with many opponents.",
  "scramble" => "Scramble — open mat / informal competition.",
  "private_lesson" => "Private lesson — one-on-one or small-group paid session. " \
                      "Filtered out of the default `events list` unless you opt in.",
  "other" => "Miscellaneous events that don't fit the other types."
}.freeze

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/wiq/commands/events.rb', line 45

def list
  params = {
    "start" => options[:start],
    "end" => options[:end],
    "per_page" => 100
  }
  params["event_type"] = options[:event_type] if options[:event_type]
  params["expand"] = options[:expand] if options[:expand]
  if options[:roster]
    options[:roster].each { |rid| (params["roster_ids[]"] ||= []) << rid }
  end

  records, total = fetch_index("/api/v1/events", params, key: "events")
  render_index(
    records, total: total,
    summary: "Listed #{records.size} events #{options[:start]}..#{options[:end]}.",
    breadcrumbs: [
      { "cmd" => "wiq events show <id>", "description" => "Inspect a single event" },
      { "cmd" => "wiq check_ins event <id>", "description" => "See check-ins for an event" }
    ]
  )
end

#show(id) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/wiq/commands/events.rb', line 83

def show(id)
  params = {}
  params["expand"] = options[:expand] if options[:expand]
  event = client.get("/api/v1/events/#{id}", params)
  render(event,
         summary: "Event #{event["id"]}#{event["name"]}",
         breadcrumbs: [
           { "cmd" => "wiq check_ins event #{event["id"]}", "description" => "See check-ins" },
           { "cmd" => "wiq reports run EventStatsReport --event #{event["id"]}",
             "description" => "Run per-event stats" }
         ])
end

#typesObject



103
104
105
106
# File 'lib/wiq/commands/events.rb', line 103

def types
  rows = TYPES.map { |type, desc| { "event_type" => type, "description" => desc } }
  render_index(rows, summary: "Canonical event_type values.")
end