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
|
||||
|
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.rating,
|
||||
submission.posted_at,
|
||||
submission.hash_int,
|
||||
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
|
||||
submission
|
||||
JOIN artist
|
||||
ON artist.id = submission.artist_id
|
||||
JOIN hashes
|
||||
ON hashes.furaffinity_id = submission.id
|
||||
WHERE
|
||||
file_id = $1
|
||||
LIMIT 10",
|
||||
@ -293,14 +292,13 @@ pub async fn search_file(
|
||||
submission.file_id,
|
||||
submission.rating,
|
||||
submission.posted_at,
|
||||
submission.hash_int,
|
||||
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
|
||||
submission
|
||||
JOIN artist
|
||||
ON artist.id = submission.artist_id
|
||||
JOIN hashes
|
||||
ON hashes.furaffinity_id = submission.id
|
||||
WHERE
|
||||
lower(filename) = lower($1)
|
||||
LIMIT 10",
|
||||
@ -315,14 +313,13 @@ pub async fn search_file(
|
||||
submission.file_id,
|
||||
submission.rating,
|
||||
submission.posted_at,
|
||||
submission.hash_int,
|
||||
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
|
||||
submission
|
||||
JOIN artist
|
||||
ON artist.id = submission.artist_id
|
||||
JOIN hashes
|
||||
ON hashes.furaffinity_id = submission.id
|
||||
WHERE
|
||||
lower(url) = lower($1)
|
||||
LIMIT 10",
|
||||
@ -337,14 +334,13 @@ pub async fn search_file(
|
||||
submission.file_id,
|
||||
submission.rating,
|
||||
submission.posted_at,
|
||||
submission.hash_int,
|
||||
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
|
||||
submission
|
||||
JOIN artist
|
||||
ON artist.id = submission.artist_id
|
||||
JOIN hashes
|
||||
ON hashes.furaffinity_id = submission.id
|
||||
WHERE
|
||||
submission.id = $1
|
||||
LIMIT 10",
|
||||
@ -364,8 +360,9 @@ pub async fn search_file(
|
||||
artists: row
|
||||
.get::<Option<String>, _>("name")
|
||||
.map(|artist| vec![artist]),
|
||||
tags: row.get("tags"),
|
||||
distance: None,
|
||||
hash: None,
|
||||
hash: row.get::<Option<i64>, _>("hash_int"),
|
||||
searched_hash: None,
|
||||
site_info: Some(SiteInfo::FurAffinity {
|
||||
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(),
|
||||
url: row.url.unwrap_or_default(),
|
||||
posted_at: row.posted_at,
|
||||
tags: None,
|
||||
hash: row.hash,
|
||||
distance: row
|
||||
.distance
|
||||
|
@ -36,6 +36,9 @@ pub struct SearchResult {
|
||||
pub rating: Option<Rating>,
|
||||
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(flatten)]
|
||||
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