Skip to content

Commit 32de879

Browse files
committed
feat(tag-details): add migration
1 parent 32d4e63 commit 32de879

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Add down migration script here
2+
3+
ALTER TABLE mod_tags DROP COLUMN display_name;
4+
5+
UPDATE mod_tags SET name = 'cheats'
6+
WHERE name = 'cheat';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- Add up migration script here
2+
3+
ALTER TABLE mod_tags ADD COLUMN display_name TEXT;
4+
5+
UPDATE mod_tags SET display_name = 'Universal'
6+
WHERE name = 'universal';
7+
UPDATE mod_tags SET display_name = 'Gameplay'
8+
WHERE name = 'gameplay';
9+
UPDATE mod_tags SET display_name = 'Editor'
10+
WHERE name = 'editor';
11+
UPDATE mod_tags SET display_name = 'Offline'
12+
WHERE name = 'offline';
13+
UPDATE mod_tags SET display_name = 'Online'
14+
WHERE name = 'online';
15+
UPDATE mod_tags SET display_name = 'Enhancement'
16+
WHERE name = 'enhancement';
17+
UPDATE mod_tags SET display_name = 'Music'
18+
WHERE name = 'music';
19+
UPDATE mod_tags SET display_name = 'Interface'
20+
WHERE name = 'interface';
21+
UPDATE mod_tags SET display_name = 'Bugfix'
22+
WHERE name = 'bugfix';
23+
UPDATE mod_tags SET display_name = 'Utility'
24+
WHERE name = 'utility';
25+
UPDATE mod_tags SET display_name = 'Performance'
26+
WHERE name = 'performance';
27+
UPDATE mod_tags SET display_name = 'Customization'
28+
WHERE name = 'customization';
29+
UPDATE mod_tags SET display_name = 'Content'
30+
WHERE name = 'content';
31+
UPDATE mod_tags SET display_name = 'Developer'
32+
WHERE name = 'developer';
33+
UPDATE mod_tags SET display_name = 'Cheat', name = 'cheat'
34+
WHERE name = 'cheats';
35+
UPDATE mod_tags SET display_name = 'Paid'
36+
WHERE name = 'paid';
37+
UPDATE mod_tags SET display_name = 'Joke'
38+
WHERE name = 'joke';
39+
UPDATE mod_tags SET display_name = 'Modtober 2024'
40+
WHERE name = 'modtober24';

src/endpoints/tags.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ pub async fn index(data: web::Data<AppData>) -> Result<impl Responder, ApiError>
1919
payload: tags,
2020
}))
2121
}
22+
23+
#[get("/v1/detailed-tags")]
24+
pub async fn detailed_index(data: web::Data<AppData>) -> Result<impl Responder, ApiError> {
25+
let mut pool = data.db.acquire().await.or(Err(ApiError::DbAcquireError))?;
26+
27+
let tags = Tag::get_tags(&mut pool).await?;
28+
29+
Ok(web::Json(ApiResponse {
30+
error: "".to_string(),
31+
payload: tags,
32+
}))
33+
}

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ async fn main() -> anyhow::Result<()> {
124124
.service(endpoints::developers::get_me)
125125
.service(endpoints::developers::update_developer)
126126
.service(endpoints::tags::index)
127+
.service(endpoints::tags::detailed_index)
127128
.service(endpoints::stats::get_stats)
128129
.service(health)
129130
})

0 commit comments

Comments
 (0)