Skip to content

Commit 02a1437

Browse files
authored
controllers/krate/metadata: Reverse versions ordering (#10311)
This reverses the order of `versions` to descending order by ID, aligning more closely with the previous descending order by semver.
1 parent 8e55b04 commit 02a1437

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

src/controllers/krate/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub async fn find_crate(
9393
let versions_and_publishers: Vec<(Version, Option<User>)> = Version::belonging_to(&krate)
9494
.left_outer_join(users::table)
9595
.select(<(Version, Option<User>)>::as_select())
96-
.order_by(versions::id)
96+
.order_by(versions::id.desc())
9797
.load(&mut conn)
9898
.await?;
9999

src/tests/routes/crates/snapshots/crates_io__tests__routes__crates__read__show.snap

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ snapshot_kind: text
3535
"repository": null,
3636
"updated_at": "[datetime]",
3737
"versions": [
38-
1,
38+
3,
3939
2,
40-
3
40+
1
4141
],
4242
"yanked": false
4343
},
@@ -58,24 +58,30 @@ snapshot_kind: text
5858
"crate_size": 0,
5959
"created_at": "[datetime]",
6060
"description": null,
61-
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
61+
"dl_path": "/api/v1/crates/foo_show/0.5.1/download",
6262
"documentation": null,
6363
"downloads": 0,
6464
"edition": null,
6565
"features": {},
6666
"has_lib": null,
6767
"homepage": null,
68-
"id": 1,
68+
"id": 3,
6969
"lib_links": null,
7070
"license": null,
7171
"links": {
72-
"authors": "/api/v1/crates/foo_show/1.0.0/authors",
73-
"dependencies": "/api/v1/crates/foo_show/1.0.0/dependencies",
74-
"version_downloads": "/api/v1/crates/foo_show/1.0.0/downloads"
72+
"authors": "/api/v1/crates/foo_show/0.5.1/authors",
73+
"dependencies": "/api/v1/crates/foo_show/0.5.1/dependencies",
74+
"version_downloads": "/api/v1/crates/foo_show/0.5.1/downloads"
7575
},
76-
"num": "1.0.0",
77-
"published_by": null,
78-
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
76+
"num": "0.5.1",
77+
"published_by": {
78+
"avatar": null,
79+
"id": 1,
80+
"login": "foo",
81+
"name": null,
82+
"url": "https://github.com/foo"
83+
},
84+
"readme_path": "/api/v1/crates/foo_show/0.5.1/readme",
7985
"repository": null,
8086
"rust_version": null,
8187
"updated_at": "[datetime]",
@@ -128,30 +134,24 @@ snapshot_kind: text
128134
"crate_size": 0,
129135
"created_at": "[datetime]",
130136
"description": null,
131-
"dl_path": "/api/v1/crates/foo_show/0.5.1/download",
137+
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
132138
"documentation": null,
133139
"downloads": 0,
134140
"edition": null,
135141
"features": {},
136142
"has_lib": null,
137143
"homepage": null,
138-
"id": 3,
144+
"id": 1,
139145
"lib_links": null,
140146
"license": null,
141147
"links": {
142-
"authors": "/api/v1/crates/foo_show/0.5.1/authors",
143-
"dependencies": "/api/v1/crates/foo_show/0.5.1/dependencies",
144-
"version_downloads": "/api/v1/crates/foo_show/0.5.1/downloads"
145-
},
146-
"num": "0.5.1",
147-
"published_by": {
148-
"avatar": null,
149-
"id": 1,
150-
"login": "foo",
151-
"name": null,
152-
"url": "https://github.com/foo"
148+
"authors": "/api/v1/crates/foo_show/1.0.0/authors",
149+
"dependencies": "/api/v1/crates/foo_show/1.0.0/dependencies",
150+
"version_downloads": "/api/v1/crates/foo_show/1.0.0/downloads"
153151
},
154-
"readme_path": "/api/v1/crates/foo_show/0.5.1/readme",
152+
"num": "1.0.0",
153+
"published_by": null,
154+
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
155155
"repository": null,
156156
"rust_version": null,
157157
"updated_at": "[datetime]",

src/tests/routes/crates/snapshots/crates_io__tests__routes__crates__read__show_all_yanked.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ snapshot_kind: text
3535
"repository": null,
3636
"updated_at": "[datetime]",
3737
"versions": [
38-
1,
39-
2
38+
2,
39+
1
4040
],
4141
"yanked": true
4242
},
@@ -57,30 +57,30 @@ snapshot_kind: text
5757
"crate_size": 0,
5858
"created_at": "[datetime]",
5959
"description": null,
60-
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
60+
"dl_path": "/api/v1/crates/foo_show/0.5.0/download",
6161
"documentation": null,
6262
"downloads": 0,
6363
"edition": null,
6464
"features": {},
6565
"has_lib": null,
6666
"homepage": null,
67-
"id": 1,
67+
"id": 2,
6868
"lib_links": null,
6969
"license": null,
7070
"links": {
71-
"authors": "/api/v1/crates/foo_show/1.0.0/authors",
72-
"dependencies": "/api/v1/crates/foo_show/1.0.0/dependencies",
73-
"version_downloads": "/api/v1/crates/foo_show/1.0.0/downloads"
71+
"authors": "/api/v1/crates/foo_show/0.5.0/authors",
72+
"dependencies": "/api/v1/crates/foo_show/0.5.0/dependencies",
73+
"version_downloads": "/api/v1/crates/foo_show/0.5.0/downloads"
7474
},
75-
"num": "1.0.0",
75+
"num": "0.5.0",
7676
"published_by": {
7777
"avatar": null,
7878
"id": 1,
7979
"login": "foo",
8080
"name": null,
8181
"url": "https://github.com/foo"
8282
},
83-
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
83+
"readme_path": "/api/v1/crates/foo_show/0.5.0/readme",
8484
"repository": null,
8585
"rust_version": null,
8686
"updated_at": "[datetime]",
@@ -95,30 +95,30 @@ snapshot_kind: text
9595
"crate_size": 0,
9696
"created_at": "[datetime]",
9797
"description": null,
98-
"dl_path": "/api/v1/crates/foo_show/0.5.0/download",
98+
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
9999
"documentation": null,
100100
"downloads": 0,
101101
"edition": null,
102102
"features": {},
103103
"has_lib": null,
104104
"homepage": null,
105-
"id": 2,
105+
"id": 1,
106106
"lib_links": null,
107107
"license": null,
108108
"links": {
109-
"authors": "/api/v1/crates/foo_show/0.5.0/authors",
110-
"dependencies": "/api/v1/crates/foo_show/0.5.0/dependencies",
111-
"version_downloads": "/api/v1/crates/foo_show/0.5.0/downloads"
109+
"authors": "/api/v1/crates/foo_show/1.0.0/authors",
110+
"dependencies": "/api/v1/crates/foo_show/1.0.0/dependencies",
111+
"version_downloads": "/api/v1/crates/foo_show/1.0.0/downloads"
112112
},
113-
"num": "0.5.0",
113+
"num": "1.0.0",
114114
"published_by": {
115115
"avatar": null,
116116
"id": 1,
117117
"login": "foo",
118118
"name": null,
119119
"url": "https://github.com/foo"
120120
},
121-
"readme_path": "/api/v1/crates/foo_show/0.5.0/readme",
121+
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
122122
"repository": null,
123123
"rust_version": null,
124124
"updated_at": "[datetime]",

0 commit comments

Comments
 (0)