mirror of
https://github.com/Syfaro/fuzzysearch.git
synced 2024-11-23 15:22:31 +00:00
Include tags in FA search.
This commit is contained in:
parent
0850e4e682
commit
25c457d8dc
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
/target
|
**/target
|
||||||
.env
|
.env
|
||||||
|
542
Cargo.lock
generated
542
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -271,14 +271,13 @@ pub async fn search_file(
|
|||||||
submission.file_id,
|
submission.file_id,
|
||||||
submission.rating,
|
submission.rating,
|
||||||
submission.posted_at,
|
submission.posted_at,
|
||||||
|
submission.hash_int,
|
||||||
artist.name,
|
artist.name,
|
||||||
hashes.id hash_id
|
array(SELECT tag.name FROM tag_to_post JOIN tag ON tag_to_post.tag_id = tag.id WHERE tag_to_post.post_id = submission.id) tags
|
||||||
FROM
|
FROM
|
||||||
submission
|
submission
|
||||||
JOIN artist
|
JOIN artist
|
||||||
ON artist.id = submission.artist_id
|
ON artist.id = submission.artist_id
|
||||||
JOIN hashes
|
|
||||||
ON hashes.furaffinity_id = submission.id
|
|
||||||
WHERE
|
WHERE
|
||||||
file_id = $1
|
file_id = $1
|
||||||
LIMIT 10",
|
LIMIT 10",
|
||||||
@ -293,14 +292,13 @@ pub async fn search_file(
|
|||||||
submission.file_id,
|
submission.file_id,
|
||||||
submission.rating,
|
submission.rating,
|
||||||
submission.posted_at,
|
submission.posted_at,
|
||||||
|
submission.hash_int,
|
||||||
artist.name,
|
artist.name,
|
||||||
hashes.id hash_id
|
array(SELECT tag.name FROM tag_to_post JOIN tag ON tag_to_post.tag_id = tag.id WHERE tag_to_post.post_id = submission.id) tags
|
||||||
FROM
|
FROM
|
||||||
submission
|
submission
|
||||||
JOIN artist
|
JOIN artist
|
||||||
ON artist.id = submission.artist_id
|
ON artist.id = submission.artist_id
|
||||||
JOIN hashes
|
|
||||||
ON hashes.furaffinity_id = submission.id
|
|
||||||
WHERE
|
WHERE
|
||||||
lower(filename) = lower($1)
|
lower(filename) = lower($1)
|
||||||
LIMIT 10",
|
LIMIT 10",
|
||||||
@ -315,14 +313,13 @@ pub async fn search_file(
|
|||||||
submission.file_id,
|
submission.file_id,
|
||||||
submission.rating,
|
submission.rating,
|
||||||
submission.posted_at,
|
submission.posted_at,
|
||||||
|
submission.hash_int,
|
||||||
artist.name,
|
artist.name,
|
||||||
hashes.id hash_id
|
array(SELECT tag.name FROM tag_to_post JOIN tag ON tag_to_post.tag_id = tag.id WHERE tag_to_post.post_id = submission.id) tags
|
||||||
FROM
|
FROM
|
||||||
submission
|
submission
|
||||||
JOIN artist
|
JOIN artist
|
||||||
ON artist.id = submission.artist_id
|
ON artist.id = submission.artist_id
|
||||||
JOIN hashes
|
|
||||||
ON hashes.furaffinity_id = submission.id
|
|
||||||
WHERE
|
WHERE
|
||||||
lower(url) = lower($1)
|
lower(url) = lower($1)
|
||||||
LIMIT 10",
|
LIMIT 10",
|
||||||
@ -337,14 +334,13 @@ pub async fn search_file(
|
|||||||
submission.file_id,
|
submission.file_id,
|
||||||
submission.rating,
|
submission.rating,
|
||||||
submission.posted_at,
|
submission.posted_at,
|
||||||
|
submission.hash_int,
|
||||||
artist.name,
|
artist.name,
|
||||||
hashes.id hash_id
|
array(SELECT tag.name FROM tag_to_post JOIN tag ON tag_to_post.tag_id = tag.id WHERE tag_to_post.post_id = submission.id) tags
|
||||||
FROM
|
FROM
|
||||||
submission
|
submission
|
||||||
JOIN artist
|
JOIN artist
|
||||||
ON artist.id = submission.artist_id
|
ON artist.id = submission.artist_id
|
||||||
JOIN hashes
|
|
||||||
ON hashes.furaffinity_id = submission.id
|
|
||||||
WHERE
|
WHERE
|
||||||
submission.id = $1
|
submission.id = $1
|
||||||
LIMIT 10",
|
LIMIT 10",
|
||||||
@ -364,8 +360,9 @@ pub async fn search_file(
|
|||||||
artists: row
|
artists: row
|
||||||
.get::<Option<String>, _>("name")
|
.get::<Option<String>, _>("name")
|
||||||
.map(|artist| vec![artist]),
|
.map(|artist| vec![artist]),
|
||||||
|
tags: row.get("tags"),
|
||||||
distance: None,
|
distance: None,
|
||||||
hash: None,
|
hash: row.get::<Option<i64>, _>("hash_int"),
|
||||||
searched_hash: None,
|
searched_hash: None,
|
||||||
site_info: Some(SiteInfo::FurAffinity {
|
site_info: Some(SiteInfo::FurAffinity {
|
||||||
file_id: row.get("file_id"),
|
file_id: row.get("file_id"),
|
||||||
|
@ -173,6 +173,7 @@ pub async fn image_query(
|
|||||||
site_id_str: row.id.unwrap_or_default().to_string(),
|
site_id_str: row.id.unwrap_or_default().to_string(),
|
||||||
url: row.url.unwrap_or_default(),
|
url: row.url.unwrap_or_default(),
|
||||||
posted_at: row.posted_at,
|
posted_at: row.posted_at,
|
||||||
|
tags: None,
|
||||||
hash: row.hash,
|
hash: row.hash,
|
||||||
distance: row
|
distance: row
|
||||||
.distance
|
.distance
|
||||||
|
@ -36,6 +36,9 @@ pub struct SearchResult {
|
|||||||
pub rating: Option<Rating>,
|
pub rating: Option<Rating>,
|
||||||
pub posted_at: Option<chrono::DateTime<chrono::Utc>>,
|
pub posted_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub tags: Option<Vec<String>>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub site_info: Option<SiteInfo>,
|
pub site_info: Option<SiteInfo>,
|
||||||
|
1
migrations/20220519161030_index_tag_post_id.down.sql
Normal file
1
migrations/20220519161030_index_tag_post_id.down.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP INDEX tag_to_post_post_id;
|
1
migrations/20220519161030_index_tag_post_id.up.sql
Normal file
1
migrations/20220519161030_index_tag_post_id.up.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE INDEX tag_to_post_post_id ON tag_to_post (post_id);
|
Loading…
Reference in New Issue
Block a user