Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fix search rules, register download route (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically authored May 11, 2022
1 parent 26d9ef5 commit 3533d2a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CLOUDFLARE_INTEGRATION=false
DATABASE_URL=postgresql://labrinth:labrinth@localhost/labrinth
DATABASE_MIN_CONNECTIONS=0
DATABASE_MAX_CONNECTIONS=16

MEILISEARCH_ADDR=http://localhost:7700
MEILISEARCH_KEY=modrinth

Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct DownloadBody {

// This is an internal route, cannot be used without key
#[patch("/_count-download", guard = "admin_key_guard")]
pub async fn version_count_patch(
pub async fn count_download(
pool: web::Data<PgPool>,
download_body: web::Json<DownloadBody>,
) -> Result<HttpResponse, ApiError> {
Expand Down
10 changes: 9 additions & 1 deletion src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ pub fn v2_config(cfg: &mut web::ServiceConfig) {
.configure(users_config)
.configure(moderation_config)
.configure(reports_config)
.configure(notifications_config),
.configure(notifications_config)
.configure(admin_config),
);
}

Expand Down Expand Up @@ -156,6 +157,13 @@ pub fn reports_config(cfg: &mut web::ServiceConfig) {
cfg.service(reports::delete_report);
}

pub fn admin_config(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("admin")
.service(admin::count_download)
);
}

#[derive(thiserror::Error, Debug)]
pub enum ApiError {
#[error("Environment Error")]
Expand Down
4 changes: 2 additions & 2 deletions src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ pub async fn search_for_project(
"relevance" => ("projects", ["downloads:desc"]),
"downloads" => ("projects_filtered", ["downloads:desc"]),
"follows" => ("projects_filtered", ["follows:desc"]),
"updated" => ("projects_filtered", ["date_created:asc"]),
"newest" => ("projects_filtered", ["date_modified:asc"]),
"updated" => ("projects_filtered", ["date_modified:desc"]),
"newest" => ("projects_filtered", ["date_created:desc"]),
i => return Err(SearchError::InvalidIndex(i.to_string())),
};

Expand Down

0 comments on commit 3533d2a

Please sign in to comment.