wiq-cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8732206776c88ba1c9d5630407e3a7a4ba6386e528cb5a7a36b2b7c8bcda3dc
4
- data.tar.gz: 499116e3d7977c22e0f44759ea59406c49265e865def76300353de0052dbf5b0
3
+ metadata.gz: bffdea54163c5b95a5cab8b219d3e5cb3a898a059d7edce13afa8ae02928b27a
4
+ data.tar.gz: 0f9e49529c6bc9fb37b75761e581d1de90a186107242a6c3092fcca55687f9ba
5
5
  SHA512:
6
- metadata.gz: 34f253c3bfcf4a7702348287da3a3e8c2458dbc818d20a73849e1b14574b9d7b38767113dd099ea065142d80e1415669813ca54199e9d61326452a6daf6f6b04
7
- data.tar.gz: 80df40a51028efe1926961e2c556a8fab8a46d28757f28360ef12d258003fbdaea031ea2933690e07a33f7729f6e165cea4db33a5491722d44eaa8e7d323498e
6
+ metadata.gz: 57f4ccba1f18ca17207739d051e94fcfb1b52b712c2d87e97fc64951acd4041d37a69f6d89d262dfde73cc44d278549d6ac9af02b67a572e3dd549dd2c58cd95
7
+ data.tar.gz: a317f13e135ab5b7a20f24b7f0c8a6640cbf84afc6a0a3e8d38d9d6483a537c302289f479b1cac0d454ca9c10485ebbcf453804decf4cdf02dbd73b822b0b933
data/docs/deferred.md CHANGED
@@ -144,10 +144,14 @@ Last updated: 2026-05-12 (after L1 ships).
144
144
  - **Echo `request_id`** in the response body or `X-Request-ID` header,
145
145
  for support correlation. Today the CLI can't give a customer a request
146
146
  ID to ship to support.
147
- - **Real location/site filter on events.** `Event.location` is free-text
148
- and not in `ransackable_attributes`. WIQ team has flagged a structured
149
- location concept as roadmap. Until then the CLI deliberately exposes
150
- no `--site` flag.
147
+ - ~~**Real location/site filter on events.**~~ SHIPPED (June 2026,
148
+ wre-506). The backend grew a structured Location model. The CLI now
149
+ exposes `wiq locations list|show` plus `--location` flags on
150
+ `events list` (repeatable → `location_ids[]`), `rosters list`
151
+ (`q[location_id_eq]`), `paid_sessions list`, `wrestlers list`,
152
+ `metrics show`, and `reports run` (args.location_id, honored by 13
153
+ report types). The legacy free-text `Event.location` remains for old
154
+ rows; serialized `location` is the display form.
151
155
  - **Subdomain discovery flow for `wiq auth login`.** PAT settings URL
152
156
  lives at `<team-subdomain>.wrestlingiq.com/settings/personal_access_tokens`.
153
157
  If a customer doesn't know their subdomain, the CLI can't deep-link
@@ -468,13 +468,16 @@ Other registration surface:
468
468
  - `expand=event_invites,event_bookings,private_lessons` — comma-separated
469
469
  CSV; pulls in nested data on the events index/show.
470
470
  - `Event.ransackable_attributes` allows
471
- `id, name, start_at, end_at, event_type, paid_session_id`. **`location`
472
- is not ransackable today.** A real location filter is on the WIQ
473
- backend roadmap (it will replace the free-text `location` column with a
474
- structured concept); until that ships the CLI doesn't expose a
475
- location/site flag. Users who need it can fetch the date range, write
476
- the results to a file, and post-process — that's not the CLI's problem
477
- to solve in v1.
471
+ `id, name, start_at, end_at, event_type, paid_session_id`. The
472
+ free-text `location` column is still not ransackable, but the
473
+ structured location filter shipped (June 2026): pass `location_ids[]`
474
+ (repeatable, dedicated param handled in `apply_event_filters`, not
475
+ Ransack) to filter on the event's `location_id`. Events with no
476
+ `location_id` are excluded from a filtered listing. The serialized
477
+ `location` field is now `Event#display_location` — the structured
478
+ Location's name when set, else the legacy free text — and `location_id`
479
+ is serialized alongside it. The CLI exposes this as
480
+ `wiq events list --location <id> [<id>...]`.
478
481
  - Soft deletes: events use `acts_as_paranoid`; the index calls
479
482
  `.without_deleted`. No "include deleted" param exposed.
480
483
  - `POST /api/v1/events` — recurring practice creation:
@@ -642,9 +645,12 @@ PaidSession-overlap convention proves load-bearing for many customers.
642
645
  demand. Until then, jbuilders are the source of truth.
643
646
  2. `request_id` echoed in response body and/or `X-Request-ID` header for
644
647
  support correlation.
645
- 3. Real location/site filter on `GET /api/v1/events` (when the backend
646
- gets a structured location concept). Until then the CLI doesn't expose
647
- a flag.
648
+ 3. ~~Real location/site filter on `GET /api/v1/events`~~ SHIPPED
649
+ (June 2026, wre-506). Structured Location model + `location_ids[]` on
650
+ events, `location_id` on paid_sessions/wrestlers/metrics/reports,
651
+ `q[location_id_eq]` on rosters, and a `GET /api/v1/locations`
652
+ resource. All exposed in the CLI via `wiq locations` and `--location`
653
+ flags.
648
654
  4. Subdomain discovery for `wiq auth login`. The PAT settings URL lives at
649
655
  `<team-subdomain>.wrestlingiq.com/settings/personal_access_tokens`; if
650
656
  the customer doesn't know their subdomain, the CLI can't deep-link
data/lib/wiq/cli.rb CHANGED
@@ -65,6 +65,9 @@ module Wiq
65
65
  desc "rosters SUBCOMMAND", "Rosters (list, show)"
66
66
  subcommand "rosters", Wiq::Commands::Rosters
67
67
 
68
+ desc "locations SUBCOMMAND", "Team locations / sites — ID discovery for --location flags (list, show)"
69
+ subcommand "locations", Wiq::Commands::Locations
70
+
68
71
  desc "prospects SUBCOMMAND", "Prospect pipeline — individual kids (list, show, summary)"
69
72
  subcommand "prospects", Wiq::Commands::Prospects
70
73
 
@@ -25,18 +25,25 @@ module Wiq
25
25
  --event-type One of `wiq events types` (practice, dual_meet, ...)
26
26
  --roster One or more roster ids (the API joins through
27
27
  roster_events)
28
+ --location One or more location ids (structured Location
29
+ records; discover via `wiq locations list`)
28
30
  --expand CSV of event_invites,event_bookings,private_lessons.
29
31
  Drops nested data into each event row.
30
32
 
31
- There is no server-side location/site filter today — `Event.location`
32
- is free-text and not in `ransackable_attributes`. A location-aware
33
- backend is on the WIQ roadmap; until then post-process client-side.
33
+ Location caveat: --location matches the event's own structured
34
+ location_id. Events with NO location set are excluded from a
35
+ filtered listing they only appear when you don't filter. The
36
+ legacy free-text `location` field still exists on old events; the
37
+ serialized `location` value is the display form (structured record
38
+ when set, else the free text).
34
39
 
35
40
  Use --all to walk every page; default is page 1, per_page=100.
36
41
  DESC
37
42
  method_option :start, type: :string, required: true, desc: "YYYY-MM-DD (team timezone)"
38
43
  method_option :end, type: :string, required: true, desc: "YYYY-MM-DD (team timezone)"
39
44
  method_option :roster, type: :array, desc: "One or more roster ids"
45
+ method_option :location, type: :array,
46
+ desc: "One or more location ids (events with no location are excluded)"
40
47
  method_option :event_type, type: :string, enum: %w[practice dual_meet tournament scramble private_lesson other],
41
48
  desc: "Filter to one event_type (see `wiq events types`)"
42
49
  method_option :expand, type: :string,
@@ -53,6 +60,9 @@ module Wiq
53
60
  if options[:roster]
54
61
  options[:roster].each { |rid| (params["roster_ids[]"] ||= []) << rid }
55
62
  end
63
+ if options[:location]
64
+ options[:location].each { |lid| (params["location_ids[]"] ||= []) << lid }
65
+ end
56
66
 
57
67
  records, total = fetch_index("/api/v1/events", params, key: "events")
58
68
  render_index(
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wiq
4
+ module Commands
5
+ class Locations < Base
6
+ desc "list", "List the team's structured locations (sites/gyms)"
7
+ long_desc <<~DESC
8
+ Locations are WIQ's structured multi-site concept — a named place
9
+ (with optional street address) that rosters, events, paid sessions,
10
+ wrestlers, metrics, and reports can be scoped to. Single-site clubs
11
+ typically have zero or one; multi-site clubs use them to slice
12
+ everything per gym.
13
+
14
+ Archived locations are hidden by default; pass --include-archived
15
+ to see them. Ordered by name server-side.
16
+
17
+ This is the ID-discovery surface for every --location flag in the
18
+ CLI:
19
+ wiq rosters list --location <id>
20
+ wiq events list --location <id> [...more ids]
21
+ wiq wrestlers list --location <id>
22
+ wiq paid_sessions list --location <id>
23
+ wiq metrics show <name> --location <id>
24
+ wiq reports run <Type> --location <id>
25
+ DESC
26
+ method_option :include_archived, type: :boolean, default: false,
27
+ desc: "Include archived locations"
28
+ method_option :all, type: :boolean, default: false
29
+ def list
30
+ params = { "per_page" => 100 }
31
+ params["include_archived"] = true if options[:include_archived]
32
+
33
+ records, total = fetch_index("/api/v1/locations", params, key: "locations")
34
+ render_index(
35
+ records, total: total,
36
+ summary: "Listed #{records.size} locations#{options[:include_archived] ? " (including archived)" : ""}.",
37
+ breadcrumbs: [
38
+ { "cmd" => "wiq locations show <id>", "description" => "Inspect a single location" },
39
+ { "cmd" => "wiq rosters list --location <id>", "description" => "Rosters at a location" },
40
+ { "cmd" => "wiq metrics show mrr --location <id>",
41
+ "description" => "Finance metrics scoped to a location (admin only)" }
42
+ ]
43
+ )
44
+ end
45
+
46
+ desc "show ID", "Fetch a single location"
47
+ long_desc <<~DESC
48
+ Full location payload: id, name, address_line1, address_line2,
49
+ city, state, postal_code, country, archived.
50
+ DESC
51
+ def show(id)
52
+ location = client.get("/api/v1/locations/#{id}")
53
+ render(location,
54
+ summary: "Location #{location["id"]} — #{location["name"]}",
55
+ breadcrumbs: [
56
+ { "cmd" => "wiq rosters list --location #{location["id"]}",
57
+ "description" => "Rosters at this location" },
58
+ { "cmd" => "wiq wrestlers list --location #{location["id"]}",
59
+ "description" => "Wrestlers on any roster at this location" }
60
+ ])
61
+ end
62
+ end
63
+ end
64
+ end
@@ -62,6 +62,13 @@ module Wiq
62
62
  Intervals: hourly, daily, weekly, monthly. Invalid values are
63
63
  silently coerced to `daily` server-side.
64
64
 
65
+ --location <id> scopes every metric to one structured location
66
+ (discover ids via `wiq locations list`). CAUTION: the server
67
+ validates the id against the team's own locations and silently
68
+ falls back to ALL locations when it doesn't match — a typo'd or
69
+ foreign id returns team-wide numbers, not an error. The CLI echoes
70
+ the requested location in `meta` so you can sanity-check.
71
+
65
72
  Currency metrics return integer cents (divide by 100 for dollars).
66
73
  Non-currency metrics return raw counts.
67
74
  DESC
@@ -70,6 +77,8 @@ module Wiq
70
77
  enum: VALID_INTERVALS, desc: "interval_group"
71
78
  method_option :start_date, type: :string, desc: "Required if --range=custom"
72
79
  method_option :end_date, type: :string, desc: "Required if --range=custom"
80
+ method_option :location, type: :numeric,
81
+ desc: "Scope to one location id (unknown ids silently mean ALL locations)"
73
82
  method_option :no_comparison, type: :boolean, default: false,
74
83
  desc: "Drop comparison_series/comparison_total from output"
75
84
  def show(name)
@@ -91,6 +100,7 @@ module Wiq
91
100
  params["start_date"] = options[:start_date]
92
101
  params["end_date"] = options[:end_date]
93
102
  end
103
+ params["location_id"] = options[:location] if options[:location]
94
104
 
95
105
  payload = client.get("/api/v1/metrics/#{name}", params)
96
106
  metrics = payload["metrics"] || {}
@@ -106,9 +116,13 @@ module Wiq
106
116
  data["comparison_total"] = metrics["comparison_total"]
107
117
  end
108
118
 
119
+ meta = { "currency_unit" => CURRENCY_METRICS.include?(name) ? "cents" : "count" }
120
+ meta["location_id"] = options[:location] if options[:location]
121
+
109
122
  render(data,
110
- summary: "metric=#{name} range=#{options[:range]} interval=#{options[:interval]}",
111
- meta: { "currency_unit" => CURRENCY_METRICS.include?(name) ? "cents" : "count" },
123
+ summary: "metric=#{name} range=#{options[:range]} interval=#{options[:interval]}" \
124
+ "#{options[:location] ? " location=#{options[:location]}" : ""}",
125
+ meta: meta,
112
126
  breadcrumbs: [
113
127
  { "cmd" => "wiq metrics list", "description" => "See all supported metrics" }
114
128
  ])
@@ -20,6 +20,10 @@ module Wiq
20
20
  recurring_registerable, not_recurring, not_recurring_with_archived,
21
21
  not_archived, dropin, trial, trial_or_dropin
22
22
 
23
+ --location <id> filters server-side to sessions stamped with that
24
+ structured location (discover ids via `wiq locations list`).
25
+ Sessions with no location are excluded when the filter is on.
26
+
23
27
  --season filters CLI-side to sessions whose [start_at, end_at] window
24
28
  overlaps the given calendar year. Pair with --all to get an exhaustive
25
29
  list.
@@ -30,11 +34,13 @@ module Wiq
30
34
  you usually don't need a follow-up call.
31
35
  DESC
32
36
  method_option :type, type: :string, enum: PRESET_TYPES, desc: "Preset scope filter"
37
+ method_option :location, type: :numeric, desc: "Filter to sessions at one location id"
33
38
  method_option :season, type: :numeric, desc: "Filter to sessions overlapping calendar year"
34
39
  method_option :all, type: :boolean, default: false
35
40
  def list
36
41
  params = { "per_page" => 50 }
37
42
  params[:type] = options[:type] if options[:type]
43
+ params["location_id"] = options[:location] if options[:location]
38
44
 
39
45
  records, total = fetch_index("/api/v1/paid_sessions", params, key: "paid_sessions")
40
46
 
@@ -26,7 +26,7 @@ module Wiq
26
26
  TYPES = {
27
27
  # ── Roster tab ───────────────────────────────────────────────
28
28
  "RosterReport" => {
29
- args: %w[roster_id append_property_ids include_archived_roster_tags],
29
+ args: %w[roster_id location_id append_property_ids include_archived_roster_tags],
30
30
  dates: :optional,
31
31
  desc: "Roster snapshot — name, weight class, academic class, age",
32
32
  recommended: true,
@@ -41,8 +41,11 @@ module Wiq
41
41
  "to roster at\" column (roster_memberships.created_at — when the " \
42
42
  "wrestler landed on the roster, NOT their registration date), " \
43
43
  "populated only for a specific --roster <id> (id > 0), not " \
44
- "--roster 0. --v1 returns fuller per-wrestler objects but drops " \
45
- "that column.",
44
+ "--roster 0. With --location <id> instead, the report scopes to " \
45
+ "wrestlers on any roster at that location (one row each) and " \
46
+ "\"Added to roster at\" becomes their EARLIEST membership across " \
47
+ "that location's rosters. --v1 returns fuller per-wrestler " \
48
+ "objects but drops that column.",
46
49
  example: "wiq reports run RosterReport --roster 42"
47
50
  },
48
51
  "FullExportWrestlerReport" => {
@@ -67,52 +70,52 @@ module Wiq
67
70
 
68
71
  # ── USAW / AAU tab ───────────────────────────────────────────
69
72
  "UsawReport" => {
70
- args: %w[roster_id],
73
+ args: %w[roster_id location_id],
71
74
  dates: :optional,
72
75
  desc: "All USA Wrestling card info on file, one row per wrestler",
73
76
  recommended: true,
74
77
  notes: "UI hides this tab when USAW collection is off (team setting)."
75
78
  },
76
79
  "UsawExpiredReport" => {
77
- args: %w[roster_id],
80
+ args: %w[roster_id location_id],
78
81
  dates: :optional,
79
82
  desc: "Wrestlers missing or with expired USAW memberships",
80
83
  notes: "Output is also a bulk-purchase upload format for USAW's system."
81
84
  },
82
85
  "UsawExportReport" => {
83
- args: %w[roster_id paid_session_id],
86
+ args: %w[roster_id location_id paid_session_id],
84
87
  dates: :optional,
85
88
  desc: "USAW bulk-purchase upload format",
86
89
  notes: "Only report that accepts paid_session_id=0 to mean " \
87
90
  "\"all sessions\"."
88
91
  },
89
92
  "AauReport" => {
90
- args: %w[roster_id],
93
+ args: %w[roster_id location_id],
91
94
  dates: :optional,
92
95
  desc: "All AAU card info on file, one row per wrestler",
93
96
  recommended: true,
94
97
  notes: "UI hides this tab when AAU collection is off (team setting)."
95
98
  },
96
99
  "AauExpiredReport" => {
97
- args: %w[roster_id],
100
+ args: %w[roster_id location_id],
98
101
  dates: :optional,
99
102
  desc: "Wrestlers missing or with expired AAU memberships"
100
103
  },
101
104
  "AauExportReport" => {
102
- args: %w[roster_id],
105
+ args: %w[roster_id location_id],
103
106
  dates: :optional,
104
107
  desc: "AAU bulk-purchase upload format"
105
108
  },
106
109
 
107
110
  # ── Stats tab ────────────────────────────────────────────────
108
111
  "WinLossReport" => {
109
- args: %w[roster_id],
112
+ args: %w[roster_id location_id],
110
113
  dates: :required,
111
114
  desc: "Wins and losses per wrestler",
112
115
  recommended: true
113
116
  },
114
117
  "RosterStatsReport" => {
115
- args: %w[roster_id],
118
+ args: %w[roster_id location_id],
116
119
  dates: :required,
117
120
  desc: "Wrestling stats per wrestler (takedowns, nearfall, etc.)",
118
121
  recommended: true
@@ -133,8 +136,10 @@ module Wiq
133
136
  recommended: true,
134
137
  notes: "One row per wrestler over the date range — totals across all " \
135
138
  "their check-ins in the window. If you want one row per " \
136
- "check-in event use CheckInFeedReport. The UI doesn't expose " \
137
- "a roster picker; counts span the whole team.",
139
+ "check-in event use CheckInFeedReport. Always team-wide: the " \
140
+ "model ignores roster_id AND location_id args. For a " \
141
+ "location-scoped attendance report use CheckInReport " \
142
+ "--location <id> instead.",
138
143
  example: "wiq reports run CheckInSummaryReport --start 2026-05-01 --end 2026-05-31"
139
144
  },
140
145
  "CheckInFeedReport" => {
@@ -144,11 +149,12 @@ module Wiq
144
149
  recommended: true,
145
150
  notes: "Useful for \"who came to the club today and what registrations " \
146
151
  "did they have at check-in time.\" Larger payload than the " \
147
- "summary.",
152
+ "summary. Always team-wide: the model ignores roster_id AND " \
153
+ "location_id args.",
148
154
  example: "wiq reports run CheckInFeedReport --start 2026-05-01 --end 2026-05-31"
149
155
  },
150
156
  "PracticeAttendanceReport" => {
151
- args: %w[roster_id],
157
+ args: %w[roster_id location_id],
152
158
  dates: :required,
153
159
  desc: "Practice-event attendance roll-up across a date range",
154
160
  recommended: false,
@@ -159,7 +165,7 @@ module Wiq
159
165
  "use CheckInSummaryReport or CheckInFeedReport instead."
160
166
  },
161
167
  "LastPracticeAttendedReport" => {
162
- args: %w[roster_id],
168
+ args: %w[roster_id location_id],
163
169
  dates: :optional,
164
170
  desc: "Days since last practice attended, per wrestler",
165
171
  recommended: true,
@@ -167,7 +173,7 @@ module Wiq
167
173
  "practice in a while — particularly for seasonal clubs."
168
174
  },
169
175
  "ChurnRiskReport" => {
170
- args: %w[roster_id days_threshold],
176
+ args: %w[roster_id location_id days_threshold],
171
177
  dates: :optional,
172
178
  desc: "Active recurring subscribers who haven't checked in within a window",
173
179
  recommended: true,
@@ -178,7 +184,7 @@ module Wiq
178
184
  example: "wiq reports run ChurnRiskReport --roster 0 --days-threshold 30"
179
185
  },
180
186
  "CheckInReport" => {
181
- args: %w[roster_id],
187
+ args: %w[roster_id location_id],
182
188
  dates: :required,
183
189
  desc: "Extended attendance — one row per check-in INCLUDING Q&A responses",
184
190
  notes: "UI labels this \"Attendance Extended (with questions).\" Same " \
@@ -333,6 +339,14 @@ module Wiq
333
339
  Common args (only those documented in TYPES are honored
334
340
  server-side):
335
341
  --roster <id> roster_id (0 = all rosters)
342
+ --location <id> location_id — scope the wrestler set to
343
+ one location (wrestlers on ANY roster at
344
+ that location, deduped to one row each).
345
+ Precedence: a specific --roster <id> (> 0)
346
+ WINS over --location; pass --location
347
+ alone (or with --roster 0) to get
348
+ location scoping. Discover ids via
349
+ `wiq locations list`.
336
350
  --paid-session <id> paid_session_id (0 = all, UsawExport only)
337
351
  --event <id> event_id (EventStatsReport)
338
352
  --fundraiser <id> fundraiser_id (Fundraiser* reports)
@@ -369,6 +383,9 @@ module Wiq
369
383
  method_option :start, type: :string, desc: "YYYY-MM-DD"
370
384
  method_option :end, type: :string, desc: "YYYY-MM-DD"
371
385
  method_option :roster, type: :numeric, desc: "args.roster_id (0 = all rosters)"
386
+ method_option :location, type: :numeric,
387
+ desc: "args.location_id — scope wrestlers to one location " \
388
+ "(a specific --roster <id> > 0 takes precedence)"
372
389
  method_option :paid_session, type: :numeric, desc: "args.paid_session_id"
373
390
  method_option :event, type: :numeric, desc: "args.event_id"
374
391
  method_option :fundraiser, type: :numeric, desc: "args.fundraiser_id"
@@ -529,6 +546,7 @@ module Wiq
529
546
 
530
547
  args = {}
531
548
  args["roster_id"] = options[:roster] if options[:roster] || options[:roster] == 0
549
+ args["location_id"] = options[:location] if options[:location]
532
550
  args["paid_session_id"] = options[:paid_session] if options[:paid_session] || options[:paid_session] == 0
533
551
  args["event_id"] = options[:event] if options[:event]
534
552
  args["fundraiser_id"] = options[:fundraiser] if options[:fundraiser]
@@ -17,12 +17,19 @@ module Wiq
17
17
  exact name. Some teams tag rosters with
18
18
  conventions like "2025-26".
19
19
 
20
+ --location <id> filters server-side (Ransack q[location_id_eq]) to
21
+ rosters stamped with that structured location. Discover ids via
22
+ `wiq locations list`. Rosters with no location are excluded when
23
+ the filter is on. Each roster row embeds its location object (or
24
+ null) so you can also group client-side without the filter.
25
+
20
26
  Each roster row embeds roster_syncers and taggings, which is what
21
27
  --season uses to filter without needing extra calls.
22
28
  DESC
23
29
  method_option :season, type: :numeric,
24
30
  desc: "Filter to rosters whose syncers point at paid sessions overlapping this year"
25
31
  method_option :season_tag, type: :string, desc: "Filter to rosters carrying this tag"
32
+ method_option :location, type: :numeric, desc: "Filter to rosters at one location id"
26
33
  method_option :archived, type: :boolean, desc: "Show only archived (true) or active (false)"
27
34
  method_option :all, type: :boolean, default: false
28
35
  def list
@@ -30,6 +37,7 @@ module Wiq
30
37
  unless options[:archived].nil?
31
38
  params["q[archived_eq]"] = options[:archived]
32
39
  end
40
+ params["q[location_id_eq]"] = options[:location] if options[:location]
33
41
 
34
42
  records, total = fetch_index("/api/v1/rosters", params, key: "rosters")
35
43
 
@@ -20,6 +20,10 @@ module Wiq
20
20
  --first-name q[first_name_cont]
21
21
  --last-name q[last_name_cont]
22
22
  --roster <id> q[rosters_id_eq] — filter to one roster
23
+ --location <id> location_id (dedicated param, not Ransack) —
24
+ wrestlers on ANY roster at that location.
25
+ Composes with the other filters. Discover
26
+ ids via `wiq locations list`.
23
27
  --weight-class q[weight_class_numeric_eq] — exact numeric
24
28
  --academic-class q[academic_class_eq] (senior, junior, …)
25
29
  --age q[age_eq]
@@ -43,6 +47,8 @@ module Wiq
43
47
  method_option :first_name, type: :string, desc: "First name (contains)"
44
48
  method_option :last_name, type: :string, desc: "Last name (contains)"
45
49
  method_option :roster, type: :numeric, desc: "Filter to a single roster id"
50
+ method_option :location, type: :numeric,
51
+ desc: "Filter to wrestlers on any roster at this location id"
46
52
  method_option :weight_class, type: :string,
47
53
  desc: "Weight class (exact numeric, e.g. 132)"
48
54
  method_option :academic_class, type: :string,
@@ -107,6 +113,7 @@ module Wiq
107
113
  params["q[first_name_cont]"] = options[:first_name] if options[:first_name]
108
114
  params["q[last_name_cont]"] = options[:last_name] if options[:last_name]
109
115
  params["q[rosters_id_eq]"] = options[:roster] if options[:roster]
116
+ params["location_id"] = options[:location] if options[:location]
110
117
  params["q[weight_class_numeric_eq]"] = options[:weight_class] if options[:weight_class]
111
118
  params["q[academic_class_eq]"] = options[:academic_class] if options[:academic_class]
112
119
  params["q[age_eq]"] = options[:age] if options[:age]
@@ -130,6 +137,7 @@ module Wiq
130
137
  bits = []
131
138
  bits << "matching #{options[:query].inspect}" if options[:query]
132
139
  bits << "in roster #{options[:roster]}" if options[:roster]
140
+ bits << "at location #{options[:location]}" if options[:location]
133
141
  bits << "weight class #{options[:weight_class]}" if options[:weight_class]
134
142
  bits << "profile_type=#{options[:profile_type]}" if profile_type_filter? && options[:profile_type] != "teammate"
135
143
  bits.empty? ? "" : " (#{bits.join(", ")})"
data/lib/wiq/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wiq
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/wiq.rb CHANGED
@@ -20,6 +20,7 @@ require "wiq/commands/registrations"
20
20
  require "wiq/commands/metrics"
21
21
  require "wiq/commands/events"
22
22
  require "wiq/commands/rosters"
23
+ require "wiq/commands/locations"
23
24
  require "wiq/commands/prospects"
24
25
  require "wiq/commands/prospect_families"
25
26
  require "wiq/commands/workflows"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: wiq
3
- description: Use this skill when the user asks about their WrestlingIQ data — rosters, attendance, check-ins, paid sessions and registrations, the prospects/leads pipeline, financial metrics, reports, USAW/AAU memberships, fundraising, or online store orders. The `wiq` CLI provides read-only access to /api/v1 via personal access tokens. Recognize phrasings like "how is our pipeline?", "who came to practice this week?", "show me the roster", "what's our MRR?", "which kids need USAW renewal?", or anything that maps to a wrestling club's admin workflows.
3
+ description: Use this skill when the user asks about their WrestlingIQ data — rosters, attendance, check-ins, paid sessions and registrations, the prospects/leads pipeline, financial metrics, reports, USAW/AAU memberships, fundraising, online store orders, or per-location/site breakdowns for multi-gym clubs. The `wiq` CLI provides read-only access to /api/v1 via personal access tokens. Recognize phrasings like "how is our pipeline?", "who came to practice this week?", "show me the roster", "what's our MRR?", "which kids need USAW renewal?", "how is the Eastside gym doing?", or anything that maps to a wrestling club's admin workflows.
4
4
  ---
5
5
 
6
6
  # WrestlingIQ CLI Skill
@@ -223,9 +223,14 @@ join date is in the default output.
223
223
  resolves to paid_session ids whose date range overlaps the calendar
224
224
  year, then filters client-side. There's no first-class Season entity
225
225
  in WIQ.
226
- - **`Event.location` is free-text and not filterable.** No `--site` or
227
- `--location` flag exists yet. A structured location concept is on the
228
- WIQ roadmap.
226
+ - **Legacy free-text `Event.location` vs structured locations.** Old
227
+ events carry a free-text `location` string; the serialized `location`
228
+ field is the display form (structured Location name/address when
229
+ `location_id` is set, else the legacy text). `--location` filters only
230
+ match the structured `location_id` — events, rosters, and paid sessions
231
+ with NO location set are excluded from filtered listings, so an empty
232
+ filtered result doesn't mean "nothing happened", it may mean "nothing
233
+ is stamped with that location yet."
229
234
  - **Index responses are wrapped.** Every `/api/v1` index returns
230
235
  `{"<resource>": [...]}` — the CLI unwraps internally, but if you ever
231
236
  hit the API directly remember to unwrap.
@@ -338,13 +343,58 @@ For exhaustive exports go through `wiq reports run RosterReport`
338
343
  `profile_type=teammate` (matching the WIQ web UI default); pass
339
344
  `--profile-type alumnus|guest|all` to widen.
340
345
 
346
+ ## Locations (multi-site clubs)
347
+
348
+ WIQ has a structured Location model (name + street address, per team).
349
+ Multi-gym clubs stamp rosters, events, and paid sessions with a
350
+ location; single-site clubs usually have none, and every `--location`
351
+ flag is simply irrelevant for them.
352
+
353
+ Discover ids first — this is the anchor for everything below:
354
+
355
+ ```bash
356
+ wiq locations list # id, name, address, archived
357
+ wiq locations list --include-archived
358
+ ```
359
+
360
+ Then scope any of these surfaces:
361
+
362
+ | Command | Flag | Semantics |
363
+ | --- | --- | --- |
364
+ | `wiq rosters list` | `--location <id>` | Rosters stamped with that location (`q[location_id_eq]`) |
365
+ | `wiq events list` | `--location <id> [<id>...]` | Events at those locations (repeatable; unset-location events excluded) |
366
+ | `wiq paid_sessions list` | `--location <id>` | Sessions stamped with that location |
367
+ | `wiq wrestlers list` | `--location <id>` | Wrestlers on ANY roster at that location; composes with other filters |
368
+ | `wiq metrics show <name>` | `--location <id>` | Per-location finance metrics (the payment-dashboard filter) |
369
+ | `wiq reports run <Type>` | `--location <id>` | Scopes the wrestler set for the 13 location-aware report types |
370
+
371
+ Three gotchas an agent must know:
372
+
373
+ 1. **Reports precedence:** a specific `--roster <id>` (> 0) WINS over
374
+ `--location` in report args. Pass `--location` alone (or with
375
+ `--roster 0`) to get location scoping. A wrestler on multiple rosters
376
+ at the location collapses to one row; RosterReport's "Added to roster
377
+ at" becomes their EARLIEST membership across that location's rosters.
378
+ `CheckInSummaryReport` / `CheckInFeedReport` ignore both args
379
+ entirely (always team-wide) — use `CheckInReport --location <id>` for
380
+ location-scoped attendance.
381
+ 2. **Metrics fail silent, not loud:** an unknown or foreign `--location`
382
+ id on `wiq metrics show` silently falls back to ALL locations —
383
+ team-wide numbers, no error. Verify the id against
384
+ `wiq locations list` before quoting per-site revenue to the user.
385
+ 3. **Nothing is auto-stamped retroactively.** Filters only match records
386
+ whose `location_id` is set. Empty filtered results on a club that
387
+ just adopted locations usually mean unstamped data, not zero
388
+ activity. Rosters/events/paid_sessions embed their `location` object
389
+ (or null) in list payloads, so you can check coverage cheaply.
390
+
341
391
  ## What's NOT available (yet)
342
392
 
343
393
  The CLI is read-only by design except for report submission. You
344
394
  cannot via this CLI:
345
395
 
346
396
  - Create/edit prospects, families, notes, check-ins, events, paid
347
- sessions, rosters, or any other resource
397
+ sessions, rosters, locations, or any other resource
348
398
  - Mint, list, or revoke PATs (use the web UI at
349
399
  `<host>/settings/personal_access_tokens`)
350
400
  - Mark attendance, advance prospect stages, log contact notes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiq-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WrestlingIQ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-29 00:00:00.000000000 Z
11
+ date: 2026-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -90,6 +90,7 @@ files:
90
90
  - lib/wiq/commands/check_ins.rb
91
91
  - lib/wiq/commands/doctor.rb
92
92
  - lib/wiq/commands/events.rb
93
+ - lib/wiq/commands/locations.rb
93
94
  - lib/wiq/commands/metrics.rb
94
95
  - lib/wiq/commands/paid_sessions.rb
95
96
  - lib/wiq/commands/prospect_families.rb