Improved tag searching
This commit is contained in:
parent
8c9bdbb58e
commit
ab43295b29
2 changed files with 21 additions and 10 deletions
|
|
@ -17,9 +17,9 @@ Still very much an early WIP.
|
|||
|
||||
- [ ] Display thumbnails on post selection
|
||||
- [ ] Text media
|
||||
- [ ] Testing
|
||||
- [ ] Improve CSS
|
||||
- [ ] User management
|
||||
- [ ] Testing
|
||||
- [ ] Lossless compression
|
||||
- [ ] Migrate to Cot...?
|
||||
|
||||
|
|
|
|||
29
src/views.rs
29
src/views.rs
|
|
@ -18,7 +18,7 @@ use chrono::Utc;
|
|||
use image::{GenericImageView, ImageFormat, ImageReader};
|
||||
use itertools::Itertools;
|
||||
use rand::Rng;
|
||||
use samey_migration::{Expr, OnConflict, Query as MigrationQuery};
|
||||
use samey_migration::{OnConflict, Query as MigrationQuery};
|
||||
use sea_orm::{
|
||||
ActiveValue::Set, ColumnTrait, Condition, EntityTrait, FromQueryResult, IntoSimpleExpr,
|
||||
ModelTrait, PaginatorTrait, QueryFilter, QuerySelect,
|
||||
|
|
@ -552,10 +552,17 @@ pub(crate) async fn search_tags(
|
|||
.collect()
|
||||
} else {
|
||||
SameyTag::find()
|
||||
.filter(Expr::cust_with_expr(
|
||||
"LOWER(\"samey_tag\".\"name\") LIKE CONCAT(?, '%')",
|
||||
stripped_tag.to_lowercase(),
|
||||
))
|
||||
.filter(
|
||||
Condition::any()
|
||||
.add(
|
||||
samey_tag::Column::NormalizedName
|
||||
.starts_with(stripped_tag.to_lowercase()),
|
||||
)
|
||||
.add(
|
||||
samey_tag::Column::NormalizedName
|
||||
.contains(format!(":{}", stripped_tag.to_lowercase())),
|
||||
),
|
||||
)
|
||||
.limit(10)
|
||||
.all(&db)
|
||||
.await?
|
||||
|
|
@ -586,10 +593,14 @@ pub(crate) async fn search_tags(
|
|||
.collect()
|
||||
} else {
|
||||
SameyTag::find()
|
||||
.filter(Expr::cust_with_expr(
|
||||
"LOWER(\"samey_tag\".\"name\") LIKE CONCAT(?, '%')",
|
||||
tag.to_lowercase(),
|
||||
))
|
||||
.filter(
|
||||
Condition::any()
|
||||
.add(samey_tag::Column::NormalizedName.starts_with(tag.to_lowercase()))
|
||||
.add(
|
||||
samey_tag::Column::NormalizedName
|
||||
.contains(format!(":{}", tag.to_lowercase())),
|
||||
),
|
||||
)
|
||||
.limit(10)
|
||||
.all(&db)
|
||||
.await?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue