Skip to content

Commit 64febe9

Browse files
authored
sort_by=ascending -> sort_by=time_and_id_ascending (#8615)
`sort_by=ascending` makes no sense, should be `sort_by=time_and_id_ascending`. My bad! Noticed while working on #7339.
1 parent ec57597 commit 64febe9

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

common/src/api/external/http_pagination.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ pub struct ScanByTimeAndId<Selector = ()> {
447447
#[serde(rename_all = "snake_case")]
448448
pub enum TimeAndIdSortMode {
449449
/// sort in increasing order of timestamp and ID, i.e., earliest first
450-
Ascending,
450+
TimeAndIdAscending,
451451
/// sort in increasing order of timestamp and ID, i.e., most recent first
452-
Descending,
452+
TimeAndIdDescending,
453453
}
454454

455455
fn default_ts_id_sort_mode() -> TimeAndIdSortMode {
456-
TimeAndIdSortMode::Ascending
456+
TimeAndIdSortMode::TimeAndIdAscending
457457
}
458458

459459
impl<T: Clone + Debug + DeserializeOwned + JsonSchema + PartialEq + Serialize>
@@ -462,8 +462,10 @@ impl<T: Clone + Debug + DeserializeOwned + JsonSchema + PartialEq + Serialize>
462462
type MarkerValue = (DateTime<Utc>, Uuid);
463463
fn direction(&self) -> PaginationOrder {
464464
match self.sort_by {
465-
TimeAndIdSortMode::Ascending => PaginationOrder::Ascending,
466-
TimeAndIdSortMode::Descending => PaginationOrder::Descending,
465+
TimeAndIdSortMode::TimeAndIdAscending => PaginationOrder::Ascending,
466+
TimeAndIdSortMode::TimeAndIdDescending => {
467+
PaginationOrder::Descending
468+
}
467469
}
468470
}
469471
fn from_query(p: &PaginatedByTimeAndId<T>) -> Result<&Self, HttpError> {
@@ -579,7 +581,7 @@ mod test {
579581
selector: (),
580582
};
581583
let scan_by_time_and_id = ScanByTimeAndId::<()> {
582-
sort_by: TimeAndIdSortMode::Ascending,
584+
sort_by: TimeAndIdSortMode::TimeAndIdAscending,
583585
selector: (),
584586
};
585587
let id: Uuid = "61a78113-d3c6-4b35-a410-23e9eae64328".parse().unwrap();
@@ -961,7 +963,7 @@ mod test {
961963
#[test]
962964
fn test_scan_by_time_and_id() {
963965
let scan = ScanByTimeAndId {
964-
sort_by: TimeAndIdSortMode::Ascending,
966+
sort_by: TimeAndIdSortMode::TimeAndIdAscending,
965967
selector: (),
966968
};
967969

@@ -982,7 +984,7 @@ mod test {
982984
let (p0, p1) = test_scan_param_common(
983985
&list,
984986
&scan,
985-
"sort_by=ascending",
987+
"sort_by=time_and_id_ascending",
986988
&item0_marker,
987989
&item_last_marker,
988990
&scan,
@@ -1005,13 +1007,13 @@ mod test {
10051007

10061008
// test descending too, why not (it caught a mistake!)
10071009
let scan_desc = ScanByTimeAndId {
1008-
sort_by: TimeAndIdSortMode::Descending,
1010+
sort_by: TimeAndIdSortMode::TimeAndIdDescending,
10091011
selector: (),
10101012
};
10111013
let (p0, p1) = test_scan_param_common(
10121014
&list,
10131015
&scan_desc,
1014-
"sort_by=descending",
1016+
"sort_by=time_and_id_descending",
10151017
&item0_marker,
10161018
&item_last_marker,
10171019
&scan,
@@ -1039,7 +1041,7 @@ mod test {
10391041

10401042
assert_eq!(
10411043
error.to_string(),
1042-
"unknown variant `nothing`, expected `ascending` or `descending`"
1044+
"unknown variant `nothing`, expected `time_and_id_ascending` or `time_and_id_descending`"
10431045
);
10441046
}
10451047
}

common/tests/output/pagination-examples.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ example pagination parameters: scan by name or id, using name ascending
2020
}
2121
example pagination parameters: scan by time and id, ascending
2222
{
23-
"sort_by": "ascending"
23+
"sort_by": "time_and_id_ascending"
2424
}
2525
example pagination parameters: page selector: by id ascending
2626
{
@@ -44,7 +44,7 @@ example pagination parameters: page selector: by name or id, using id ascending
4444
}
4545
example pagination parameters: page selector: by time and id, ascending
4646
{
47-
"sort_by": "ascending",
47+
"sort_by": "time_and_id_ascending",
4848
"last_seen": [
4949
"2025-03-20T10:30:45Z",
5050
"61a78113-d3c6-4b35-a410-23e9eae64328"

common/tests/output/pagination-schema.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ schema for pagination parameters: page selector, scan by time and id
306306
"minItems": 2
307307
},
308308
"sort_by": {
309-
"default": "ascending",
309+
"default": "time_and_id_ascending",
310310
"allOf": [
311311
{
312312
"$ref": "#/definitions/TimeAndIdSortMode"
@@ -322,14 +322,14 @@ schema for pagination parameters: page selector, scan by time and id
322322
"description": "sort in increasing order of timestamp and ID, i.e., earliest first",
323323
"type": "string",
324324
"enum": [
325-
"ascending"
325+
"time_and_id_ascending"
326326
]
327327
},
328328
{
329329
"description": "sort in increasing order of timestamp and ID, i.e., most recent first",
330330
"type": "string",
331331
"enum": [
332-
"descending"
332+
"time_and_id_descending"
333333
]
334334
}
335335
]

openapi/nexus-internal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8032,14 +8032,14 @@
80328032
"description": "sort in increasing order of timestamp and ID, i.e., earliest first",
80338033
"type": "string",
80348034
"enum": [
8035-
"ascending"
8035+
"time_and_id_ascending"
80368036
]
80378037
},
80388038
{
80398039
"description": "sort in increasing order of timestamp and ID, i.e., most recent first",
80408040
"type": "string",
80418041
"enum": [
8042-
"descending"
8042+
"time_and_id_descending"
80438043
]
80448044
}
80458045
]

openapi/nexus.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27154,14 +27154,14 @@
2715427154
"description": "sort in increasing order of timestamp and ID, i.e., earliest first",
2715527155
"type": "string",
2715627156
"enum": [
27157-
"ascending"
27157+
"time_and_id_ascending"
2715827158
]
2715927159
},
2716027160
{
2716127161
"description": "sort in increasing order of timestamp and ID, i.e., most recent first",
2716227162
"type": "string",
2716327163
"enum": [
27164-
"descending"
27164+
"time_and_id_descending"
2716527165
]
2716627166
}
2716727167
]

0 commit comments

Comments
 (0)