Minor fixes to orderings and permission serialization (#102)

* Fix latest_version in search results

* Handle users with invalid permissions instead of skipping them

* Specify order of some queries, fix serialization of permissions

* Run sqlx prepare
This commit is contained in:
Aeledfyr
2020-11-10 10:27:36 -06:00
committed by GitHub
parent 578d673a4e
commit da911bfeb8
7 changed files with 83 additions and 18 deletions

View File

@@ -22,7 +22,7 @@ pub async fn index_local(pool: PgPool) -> Result<Vec<UploadSearchMod>, IndexingE
if let Ok(mod_data) = result {
let versions = sqlx::query!(
"
SELECT gv.version FROM versions
SELECT DISTINCT gv.version, gv.created FROM versions
INNER JOIN game_versions_versions gvv ON gvv.joining_version_id=versions.id
INNER JOIN game_versions gv ON gvv.game_version_id=gv.id
WHERE versions.mod_id = $1
@@ -90,7 +90,7 @@ pub async fn index_local(pool: PgPool) -> Result<Vec<UploadSearchMod>, IndexingE
// minecraft that this mod has a version that supports; it doesn't
// take betas or other info into account.
let latest_version = versions
.get(0)
.last()
.cloned()
.map(Cow::Owned)
.unwrap_or_else(|| Cow::Borrowed(""));
@@ -134,7 +134,7 @@ pub async fn query_one(
let versions = sqlx::query!(
"
SELECT gv.version FROM versions
SELECT DISTINCT gv.version, gv.created FROM versions
INNER JOIN game_versions_versions gvv ON gvv.joining_version_id=versions.id
INNER JOIN game_versions gv ON gvv.game_version_id=gv.id
WHERE versions.mod_id = $1
@@ -202,7 +202,7 @@ pub async fn query_one(
// minecraft that this mod has a version that supports; it doesn't
// take betas or other info into account.
let latest_version = versions
.get(0)
.last()
.cloned()
.map(Cow::Owned)
.unwrap_or_else(|| Cow::Borrowed(""));