Skip to content

Commit

Permalink
Add sqlx queries
Browse files Browse the repository at this point in the history
  • Loading branch information
LetrixZ committed Jul 20, 2024
1 parent 86a305c commit e213736
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/src/api/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
use crate::db;
use anyhow::anyhow;
use axum::extract::{Path, Query, State};
use serde::{Deserialize, Serialize};
use serde::Serialize;
use std::{collections::HashMap, fmt::Display, str::FromStr};
use tokio::sync::oneshot;

Expand Down Expand Up @@ -210,7 +210,7 @@ pub async fn taxonomy(State(state): State<AppState>) -> Result<ApiJson<TaxonomyT

let events = sqlx::query!("SELECT COALESCE(json_agg(json_build_object('id', id, 'name', name, 'slug', slug) ORDER BY name), '[]') events FROM events")
.fetch_one(&state.pool)
.await?;
.await?;

let publishers = sqlx::query!("SELECT COALESCE(json_agg(json_build_object('id', id, 'name', name, 'slug', slug) ORDER BY name), '[]') publishers FROM publishers")
.fetch_one(&state.pool)
Expand Down
4 changes: 2 additions & 2 deletions server/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ fn add_tag_matches(qb: &mut QueryBuilder<Postgres>, value: &str, blacklist: &[St
}

for taxonomy in blacklist {
let splits = &taxonomy.split(":").collect::<Vec<&str>>();
let namespace = splits.get(0);
let splits = &taxonomy.split(':').collect::<Vec<&str>>();
let namespace = splits.first();
let taxonomy_id = splits.get(1).and_then(|s| s.parse::<i64>().ok());

if let (Some(namespace), Some(id)) = (namespace, taxonomy_id) {
Expand Down

0 comments on commit e213736

Please sign in to comment.