Change index interval, add slug to search documents (#110)

* Change index interval, add slug to search documents

* Allow the removal of '@' for slug get

* Fix

* Remove name and rename side type

* Run prepare
This commit is contained in:
Geometrically
2020-12-13 18:10:58 -07:00
committed by GitHub
parent df5684a9f8
commit f0b73fd696
14 changed files with 486 additions and 533 deletions

View File

@@ -14,7 +14,7 @@ pub async fn index_local(pool: PgPool) -> Result<Vec<UploadSearchMod>, IndexingE
let mut mods = sqlx::query!(
"
SELECT m.id, m.title, m.description, m.downloads, m.icon_url, m.body_url, m.published, m.updated, m.team_id, m.status FROM mods m
SELECT m.id, m.title, m.description, m.downloads, m.icon_url, m.body_url, m.published, m.updated, m.team_id, m.status, m.slug FROM mods m
"
).fetch(&pool);
@@ -129,6 +129,7 @@ pub async fn index_local(pool: PgPool) -> Result<Vec<UploadSearchMod>, IndexingE
modified_timestamp: mod_data.updated.timestamp(),
latest_version,
host: Cow::Borrowed("modrinth"),
slug: mod_data.slug,
});
}
}
@@ -142,7 +143,7 @@ pub async fn query_one(
) -> Result<UploadSearchMod, IndexingError> {
let mod_data = sqlx::query!(
"
SELECT m.id, m.title, m.description, m.downloads, m.icon_url, m.body_url, m.published, m.updated, m.team_id
SELECT m.id, m.title, m.description, m.downloads, m.icon_url, m.body_url, m.published, m.updated, m.team_id, m.slug
FROM mods m
WHERE id = $1
",
@@ -241,5 +242,6 @@ pub async fn query_one(
modified_timestamp: mod_data.updated.timestamp(),
latest_version,
host: Cow::Borrowed("modrinth"),
slug: mod_data.slug,
})
}

View File

@@ -62,6 +62,7 @@ pub struct SearchConfig {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UploadSearchMod {
pub mod_id: String,
pub slug: Option<String>,
pub author: String,
pub title: String,
pub description: String,
@@ -96,6 +97,7 @@ pub struct SearchResults {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ResultSearchMod {
pub mod_id: String,
pub slug: Option<String>,
pub author: String,
pub title: String,
pub description: String,