Skip to content

Commit 54b9a7c

Browse files
authored
Update dispatch filter for recurrence and end time [No Enum Alternative] (#184)
Alternative to #183 fixes #161 [Sanctioned by Tom ™️ ](#161 (comment))
2 parents ec978fc + 4e14d92 commit 54b9a7c

File tree

2 files changed

+60
-27
lines changed

2 files changed

+60
-27
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ In this release, we have made some changes to the API to improve the user experi
2121
* Add YEARLY frequency to the recurrence definition.
2222
* Add parameters for pagination and sorting.
2323
* Documentation of valid values for `count` and `interval` fields was added.
24+
* Extended filter parameters for recurrence and end time.
2425

2526
## Bug Fixes
2627

proto/frequenz/api/dispatch/v1/dispatch.proto

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,68 @@ message DispatchDetail {
186186

187187
// Filter parameter for specifying multiple time intervals
188188
message TimeIntervalFilter {
189-
// Filter by start_time >= this timestamp
190-
google.protobuf.Timestamp start_from = 1;
189+
// Filter by time >= this timestamp.
190+
google.protobuf.Timestamp from = 1;
191191

192-
// Filter by start_time < this timestamp
193-
google.protobuf.Timestamp start_to = 2;
192+
// Filter by time < this timestamp.
193+
google.protobuf.Timestamp to = 2;
194+
}
195+
196+
// Parameters for filtering the dispatch list
197+
message DispatchFilter {
198+
message RecurrenceFilter {
199+
// Filter by recurring status
200+
// True: Only recurring dispatches will be returned.
201+
// False: Only non-recurring dispatches will be returned.
202+
// Unset: Both recurring and non-recurring dispatches will be returned,
203+
// recurring dispatches will be filtered based on the recurrence
204+
// filter, while non-recurring dispatches will be returned regardless.
205+
// Examples:
206+
// - To retrieve only recurring dispatches:
207+
// filter { recurrence_filter { is_recurring: true } }
208+
// - To retrieve only non-recurring dispatches:
209+
// filter { recurrence_filter { is_recurring: false } }
210+
// - To retrieve all dispatches:
211+
// filter { recurrence_filter {} }
212+
// - To retrieve only recurring dispatches with a specific frequency:
213+
// filter { recurrence_filter { is_recurring: true, freq: [FREQUENCY_DAILY] } }
214+
// - To retrieve only recurring dispatches with a specific frequency but
215+
// also include non-recurring dispatches:
216+
// filter { recurrence_filter { freq: [FREQUENCY_DAILY] } }
217+
218+
// - only_recurring = true: Only recurring dispatches will be returned.
219+
optional bool is_recurring = 1;
220+
221+
// Filter by frequency
222+
// If not specified, all frequencies will be returned.
223+
repeated RecurrenceRule.Frequency freqs = 2;
224+
}
225+
226+
// Optional filter by component ID or category.
227+
repeated ComponentSelector selectors = 1;
228+
229+
// Optional filter by active status.
230+
// If this field is not set, dispatches of any active status will be included.
231+
optional bool is_active = 2;
232+
233+
// Optional filter by dry run status.
234+
// If this field is not set, dispatches of any dry run status will be included.
235+
optional bool is_dry_run = 3;
236+
237+
// Optional recurrence filter
238+
// If not specified both types will be returned.
239+
RecurrenceFilter recurrence_filter = 4;
194240

195-
// Filter by recurrence.end_criteria.until >= this timestamp
196-
google.protobuf.Timestamp end_from = 3;
241+
// Optional filter by start time.
242+
// If no interval is provided, all dispatches will be returned.
243+
TimeIntervalFilter start_time_interval = 5;
197244

198-
// Filter by recurrence.end_criteria.until < this timestamp
199-
google.protobuf.Timestamp end_to = 4;
245+
// Optional filter by end time
246+
// Filter dispatches based on their explicit end time.
247+
TimeIntervalFilter end_time_interval = 6;
248+
249+
// Optional filter by update time
250+
TimeIntervalFilter update_time_interval = 7;
200251
}
201252

202253
// Parameter for controlling which components a dispatch applies to
@@ -406,25 +457,6 @@ message ListMicrogridDispatchesRequest {
406457
frequenz.api.common.v1.pagination.PaginationParams pagination_params = 4;
407458
}
408459

409-
// Parameters for filtering the dispatch list
410-
message DispatchFilter {
411-
// Filter by component ID or category
412-
repeated ComponentSelector selectors = 1;
413-
414-
// Filter by time interval
415-
// If no interval is provided, all dispatches starting from the
416-
// current timestamp will be included.
417-
TimeIntervalFilter time_interval = 2;
418-
419-
// Filter by active status
420-
// If this field is not set, dispatches of any active status will be included.
421-
optional bool is_active = 3;
422-
423-
// Filter by dry run status
424-
// If this field is not set, dispatches of any dry run status will be included.
425-
optional bool is_dry_run = 4;
426-
}
427-
428460
// A list of dispatches
429461
message ListMicrogridDispatchesResponse {
430462
// The dispatches

0 commit comments

Comments
 (0)