mirror of
https://github.com/modrinth/code.git
synced 2026-07-31 21:26:40 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c3be1092 | ||
|
|
0440ef22f1 |
@@ -692,6 +692,12 @@ components:
|
||||
type: string
|
||||
description: The ID of the project
|
||||
example: AABBCCDD
|
||||
all_project_types:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: All project types across every version of the project, unlike `project_type` which only reflects a version-specific type
|
||||
example: [mod, plugin, datapack]
|
||||
author:
|
||||
type: string
|
||||
description: The username of the project's author
|
||||
@@ -748,6 +754,7 @@ components:
|
||||
- client_side
|
||||
- server_side
|
||||
- project_id
|
||||
- all_project_types
|
||||
- author
|
||||
- versions
|
||||
- follows
|
||||
@@ -1948,6 +1955,7 @@ paths:
|
||||
|
||||
These are the most commonly used facet types:
|
||||
- `project_type`
|
||||
- `all_project_types` (matches against every project type across all of the project's versions, not just the primary/version-specific type)
|
||||
- `categories` (loaders are lumped in with categories in search)
|
||||
- `versions`
|
||||
- `client_side`
|
||||
|
||||
@@ -15,6 +15,7 @@ pub struct LegacySearchResults {
|
||||
pub struct LegacyResultSearchProject {
|
||||
pub project_id: String,
|
||||
pub project_type: String,
|
||||
pub all_project_types: Vec<String>,
|
||||
pub slug: Option<String>,
|
||||
pub author: String,
|
||||
#[serde(default)]
|
||||
@@ -136,6 +137,7 @@ impl LegacyResultSearchProject {
|
||||
|
||||
Self {
|
||||
project_type,
|
||||
all_project_types: result_search_project.all_project_types,
|
||||
client_side,
|
||||
server_side,
|
||||
versions,
|
||||
|
||||
@@ -405,6 +405,14 @@ impl SearchField {
|
||||
optional: true,
|
||||
token_separators: &["-"],
|
||||
},
|
||||
SearchField::AllProjectTypes => TypesenseFieldSpec {
|
||||
path: "all_project_types",
|
||||
ty: "string[]",
|
||||
facet: true,
|
||||
sort: false,
|
||||
optional: true,
|
||||
token_separators: &["-"],
|
||||
},
|
||||
SearchField::ProjectId => TypesenseFieldSpec {
|
||||
path: "project_id",
|
||||
ty: "string",
|
||||
|
||||
@@ -495,6 +495,20 @@ async fn build_search_documents(
|
||||
.flat_map(|x| x.loaders.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// all valid project types across every version of the project, so that
|
||||
// filters can exclude projects that have *any* version of a given
|
||||
// project type (unlike the version-specific `project_types` field).
|
||||
let mut all_project_types = versions
|
||||
.iter()
|
||||
.flat_map(|x| x.project_types.clone())
|
||||
.collect::<Vec<_>>();
|
||||
all_project_types.sort();
|
||||
all_project_types.dedup();
|
||||
exp::compat::correct_project_types(
|
||||
&project.components,
|
||||
&mut all_project_types,
|
||||
);
|
||||
|
||||
for version in versions {
|
||||
let version_fields = VersionField::from_query_json(
|
||||
version.version_fields,
|
||||
@@ -609,6 +623,7 @@ async fn build_search_documents(
|
||||
slug: project.slug.clone(),
|
||||
// TODO
|
||||
project_types,
|
||||
all_project_types: all_project_types.clone(),
|
||||
gallery: gallery.clone(),
|
||||
featured_gallery: featured_gallery.clone(),
|
||||
open_source,
|
||||
|
||||
@@ -202,6 +202,7 @@ pub enum SearchField {
|
||||
Author,
|
||||
License,
|
||||
ProjectTypes,
|
||||
AllProjectTypes,
|
||||
ProjectId,
|
||||
OpenSource,
|
||||
Environment,
|
||||
@@ -238,6 +239,7 @@ pub struct UploadSearchProject {
|
||||
pub project_id: String,
|
||||
//
|
||||
pub project_types: Vec<String>,
|
||||
pub all_project_types: Vec<String>,
|
||||
pub slug: Option<String>,
|
||||
pub author: String,
|
||||
pub author_id: String,
|
||||
@@ -307,6 +309,8 @@ pub struct ResultSearchProject {
|
||||
pub version_id: String,
|
||||
pub project_id: String,
|
||||
pub project_types: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub all_project_types: Vec<String>,
|
||||
pub slug: Option<String>,
|
||||
pub author: String,
|
||||
#[serde(default)]
|
||||
@@ -355,6 +359,7 @@ impl From<UploadSearchProject> for ResultSearchProject {
|
||||
version_id: source.version_id,
|
||||
project_id: source.project_id,
|
||||
project_types: source.project_types,
|
||||
all_project_types: source.all_project_types,
|
||||
slug: source.slug,
|
||||
author: source.author,
|
||||
author_id: Some(source.author_id),
|
||||
|
||||
@@ -1742,6 +1742,7 @@ export namespace Labrinth {
|
||||
export interface ResultSearchProject {
|
||||
project_id: string
|
||||
project_type: string
|
||||
all_project_types: string[]
|
||||
slug: string | null
|
||||
author: string
|
||||
author_id: string | null
|
||||
@@ -1779,6 +1780,7 @@ export namespace Labrinth {
|
||||
version_id: string
|
||||
project_id: string
|
||||
project_types: string[]
|
||||
all_project_types: string[]
|
||||
slug: string | null
|
||||
author: string
|
||||
author_id: string | null
|
||||
|
||||
Reference in New Issue
Block a user