Skip to content

Commit 2c1f555

Browse files
committed
Cleanup syntax when retrieving items from the database.
1 parent d7e890f commit 2c1f555

File tree

6 files changed

+30
-24
lines changed

6 files changed

+30
-24
lines changed

src/database/common/project.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ pub async fn refresh_common_projects(db_pool: &Pool) -> Result<()> {
158158
pub async fn get_common_projects(db_pool: &Pool) -> Result<Vec<CommonProject>> {
159159
let db_client = db_pool.get().await?;
160160

161-
let entities = common_project::get_common_projects()
161+
let projects = common_project::get_common_projects()
162162
.bind(&db_client)
163163
.all()
164-
.await?;
165-
166-
let projects = entities.into_iter().map(|x| x.into()).collect();
164+
.await?
165+
.into_iter()
166+
.map(|x| x.into())
167+
.collect();
167168

168169
Ok(projects)
169170
}

src/database/common/search_result.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,13 @@ pub struct SearchResultHangar {
191191
pub async fn search_projects(db_pool: &Pool, params: &SearchParams) -> Result<Vec<SearchResult>> {
192192
let db_client = db_pool.get().await?;
193193

194-
let entities = search_result::search_projects()
194+
let projects = search_result::search_projects()
195195
.params(&db_client, &params.clone().into())
196196
.all()
197-
.await?;
198-
199-
let projects = entities.into_iter().map(|x| x.into()).collect();
197+
.await?
198+
.into_iter()
199+
.map(|x| x.into())
200+
.collect();
200201

201202
Ok(projects)
202203
}

src/database/hangar/project.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ pub async fn upsert_hangar_project(db_pool: &Pool, project: &HangarProject) -> R
129129
pub async fn get_hangar_projects(db_pool: &Pool) -> Result<Vec<HangarProject>> {
130130
let db_client = db_pool.get().await?;
131131

132-
let entities = hangar_project::get_hangar_projects()
132+
let projects = hangar_project::get_hangar_projects()
133133
.bind(&db_client)
134134
.all()
135-
.await?;
136-
137-
let projects = entities.into_iter().map(|x| x.into()).collect();
135+
.await?
136+
.into_iter()
137+
.map(|x| x.into())
138+
.collect();
138139

139140
Ok(projects)
140141
}

src/database/modrinth/project.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ pub async fn upsert_modrinth_project(db_pool: &Pool, project: &ModrinthProject)
132132
pub async fn get_modrinth_projects(db_pool: &Pool) -> Result<Vec<ModrinthProject>> {
133133
let db_client = db_pool.get().await?;
134134

135-
let entities = modrinth_project::get_modrinth_projects()
135+
let projects = modrinth_project::get_modrinth_projects()
136136
.bind(&db_client)
137137
.all()
138-
.await?;
139-
140-
let projects = entities.into_iter().map(|x| x.into()).collect();
138+
.await?
139+
.into_iter()
140+
.map(|x| x.into())
141+
.collect();
141142

142143
Ok(projects)
143144
}

src/database/spigot/author.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ pub async fn insert_spigot_author(db_pool: &Pool, author: &SpigotAuthor) -> Resu
6464
pub async fn get_spigot_authors(db_pool: &Pool) -> Result<Vec<SpigotAuthor>> {
6565
let db_client = db_pool.get().await?;
6666

67-
let entities = spigot_author::get_spigot_authors()
67+
let authors = spigot_author::get_spigot_authors()
6868
.bind(&db_client)
6969
.all()
70-
.await?;
71-
72-
let authors = entities.into_iter().map(|x| x.into()).collect();
70+
.await?
71+
.into_iter()
72+
.map(|x| x.into())
73+
.collect();
7374

7475
Ok(authors)
7576
}

src/database/spigot/resource.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ pub async fn upsert_spigot_resource(db_pool: &Pool, resource: &SpigotResource) -
141141
pub async fn get_spigot_resources(db_pool: &Pool) -> Result<Vec<SpigotResource>> {
142142
let db_client = db_pool.get().await?;
143143

144-
let entities = spigot_resource::get_spigot_resources()
144+
let resources = spigot_resource::get_spigot_resources()
145145
.bind(&db_client)
146146
.all()
147-
.await?;
148-
149-
let resources = entities.into_iter().map(|x| x.into()).collect();
147+
.await?
148+
.into_iter()
149+
.map(|x| x.into())
150+
.collect();
150151

151152
Ok(resources)
152153
}

0 commit comments

Comments
 (0)