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