Skip to content

Commit a59b18c

Browse files
committed
Reduce info sent for projects
1 parent 4c66b9f commit a59b18c

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

apps/labrinth/src/routes/internal/moderation/tech_review.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,26 @@ pub struct SearchResponse {
273273
/// List of reports returned.
274274
pub reports: Vec<FileReport>,
275275
/// Fetched project information for projects in the returned reports.
276-
pub projects: HashMap<ProjectId, Project>,
276+
pub projects: HashMap<ProjectId, ProjectModerationInfo>,
277277
/// Fetched moderation threads for projects in the returned reports.
278278
pub threads: HashMap<ThreadId, DBThread>,
279279
/// Fetched owner information for projects.
280280
pub ownership: HashMap<ProjectId, Ownership>,
281281
}
282282

283+
/// Limited set of project information returned by [`search_projects`].
284+
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
285+
pub struct ProjectModerationInfo {
286+
/// Projecet ID.
287+
pub id: ProjectId,
288+
/// Project name.
289+
pub name: String,
290+
/// The aggregated project typos of the versions of this project
291+
pub project_types: Vec<String>,
292+
/// The URL of the icon of the project
293+
pub icon_url: Option<String>,
294+
}
295+
283296
/// Searches all projects which are awaiting technical review.
284297
#[utoipa::path(
285298
security(("bearer_auth" = [])),
@@ -434,7 +447,20 @@ async fn search_projects(
434447

435448
Ok(web::Json(SearchResponse {
436449
reports,
437-
projects,
450+
projects: projects
451+
.into_iter()
452+
.map(|(id, project)| {
453+
(
454+
id,
455+
ProjectModerationInfo {
456+
id,
457+
name: project.name,
458+
project_types: project.project_types,
459+
icon_url: project.icon_url,
460+
},
461+
)
462+
})
463+
.collect(),
438464
threads,
439465
ownership,
440466
}))

0 commit comments

Comments
 (0)