Commit 7da86e2
fix the timeseries group office filtering (#1709)
# Fix timeseries/group endpoint returning groups for all offices when
include-assigned=false
## Problem
The `/timeseries/group` endpoint was returning timeseries groups from
all offices when the `include-assigned=false` query
parameter was set, instead of respecting the `group-office-id` and
`category-office-id` filters.
### Example
Query:
GET
/timeseries/group?office=MVP&group-office-id=MVP&include-assigned=false×eries-category-like=SHEF%20Export
Expected: Only groups with `office-id=MVP`
Actual: Groups from MVP, SWT, LRN, SAJ, SAM and other offices were
returned
## Root Cause
The `TimeSeriesGroupDao.getTimeSeriesGroups()` method branches based on
`includeAssigned`:
- When `includeAssigned=true`: calls `getTimeSeriesGroupsWhere()` which
applies office filters
- When `includeAssigned=false`: calls
`getTimeSeriesGroupsWithoutAssigned()` which was NOT receiving or
applying the
office filter parameters
## Solution
Updated `getTimeSeriesGroupsWithoutAssigned()` to:
1. Accept `groupOfficeId` and `categoryOfficeId` parameters
2. Apply the same office filtering logic as `getTimeSeriesGroupsWhere()`
This ensures consistent behavior regardless of the `include-assigned`
parameter value.
## Changes
-
**cwms-data-api/src/main/java/cwms/cda/data/dao/TimeSeriesGroupDao.java**
- Modified `getTimeSeriesGroupsWithoutAssigned()` signature to accept
office parameters
- Added office filtering conditions to the query
- Updated method call to pass the parameters
-
**cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesGroupControllerTestIT.java**
- Added `test_get_all_groups_without_assigned_filters_by_office()` to
validate office filtering works with
`include-assigned=false`
- Test leverages existing test data (SPK and CWMS offices with different
groups)
## Testing
- New test PASSED ✅
- Verifies that when querying with `GROUP_OFFICE_ID=SPK` and
`include-assigned=false`, only groups from SPK office are
returned
- Existing TimeSeriesGroupControllerTestIT tests continue to pass
## Impact
- Fixes endpoint behavior to match documented API
- No breaking changes - only corrects the filtering to work as expected
Co-authored-by: Eric Novotny <nov00002@umn.edu>1 parent 8ffecfa commit 7da86e2
2 files changed
Lines changed: 58 additions & 12 deletions
File tree
- cwms-data-api/src
- main/java/cwms/cda/data/dao
- test/java/cwms/cda/api
Lines changed: 22 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
230 | 239 | | |
231 | 240 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2382 | 2382 | | |
2383 | 2383 | | |
2384 | 2384 | | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
2385 | 2421 | | |
0 commit comments