mirror of
https://github.com/Syfaro/fuzzysearch.git
synced 2024-11-10 17:02:38 +00:00
Fix schema name.
This commit is contained in:
parent
880c5f385e
commit
ceeef0b9e9
@ -66,7 +66,7 @@ async fn main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
db.execute(
|
db.execute(
|
||||||
"CREATE TABLE IF NOT EXISTS post (id INTEGER PRIMARY KEY, data JSONB)",
|
"CREATE TABLE IF NOT EXISTS e621 (id INTEGER PRIMARY KEY, hash BIGINT, data JSONB, hash_error TEXT)",
|
||||||
&[],
|
&[],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@ -84,13 +84,13 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.expect("Unable to create function");
|
.expect("Unable to create function");
|
||||||
|
|
||||||
db.execute("DROP TRIGGER IF EXISTS call_extract_post_data ON post", &[])
|
db.execute("DROP TRIGGER IF EXISTS call_extract_post_data ON e621", &[])
|
||||||
.await
|
.await
|
||||||
.expect("Unable to drop trigger");
|
.expect("Unable to drop trigger");
|
||||||
db.execute("CREATE TRIGGER call_extract_post_data BEFORE INSERT ON post FOR EACH ROW EXECUTE PROCEDURE extract_post_data()", &[]).await.expect("Unable to create trigger");
|
db.execute("CREATE TRIGGER call_extract_post_data BEFORE INSERT ON e621 FOR EACH ROW EXECUTE PROCEDURE extract_post_data()", &[]).await.expect("Unable to create trigger");
|
||||||
|
|
||||||
let mut min_id = db
|
let mut min_id = db
|
||||||
.query_one("SELECT MIN(id) FROM post", &[])
|
.query_one("SELECT MIN(id) FROM e621", &[])
|
||||||
.await
|
.await
|
||||||
.map(|row| row.get("min"))
|
.map(|row| row.get("min"))
|
||||||
.expect("Unable to get min post");
|
.expect("Unable to get min post");
|
||||||
@ -109,7 +109,7 @@ async fn main() {
|
|||||||
min_id = ids.into_iter().min();
|
min_id = ids.into_iter().min();
|
||||||
|
|
||||||
db.execute(
|
db.execute(
|
||||||
"INSERT INTO post (data) SELECT json_array_elements($1::json)",
|
"INSERT INTO e621 (data) SELECT json_array_elements($1::json)",
|
||||||
&[&post_data],
|
&[&post_data],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -45,7 +45,7 @@ async fn load_next_posts(
|
|||||||
id,
|
id,
|
||||||
data->>'file_url' file_url
|
data->>'file_url' file_url
|
||||||
FROM
|
FROM
|
||||||
post
|
e621
|
||||||
WHERE
|
WHERE
|
||||||
hash IS NULL AND
|
hash IS NULL AND
|
||||||
hash_error IS NULL AND
|
hash_error IS NULL AND
|
||||||
@ -109,7 +109,7 @@ async fn main() {
|
|||||||
db.get()
|
db.get()
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.execute("UPDATE post SET hash = $2 WHERE id = $1", &[&id, &num])
|
.execute("UPDATE e621 SET hash = $2 WHERE id = $1", &[&id, &num])
|
||||||
.await
|
.await
|
||||||
.expect("Unable to update hash in database");
|
.expect("Unable to update hash in database");
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE post SET hash_error = $2 WHERE id = $1",
|
"UPDATE e621 SET hash_error = $2 WHERE id = $1",
|
||||||
&[&id, &desc],
|
&[&id, &desc],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -58,7 +58,7 @@ async fn main() {
|
|||||||
artists_agg.artists artists,
|
artists_agg.artists artists,
|
||||||
sources_agg.sources sources
|
sources_agg.sources sources
|
||||||
FROM
|
FROM
|
||||||
post,
|
e621,
|
||||||
LATERAL (
|
LATERAL (
|
||||||
SELECT array_agg(v) artists FROM jsonb_array_elements_text(data->'artist') v
|
SELECT array_agg(v) artists FROM jsonb_array_elements_text(data->'artist') v
|
||||||
) artists_agg,
|
) artists_agg,
|
||||||
@ -85,9 +85,17 @@ async fn main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for row in rows {
|
for row in rows {
|
||||||
|
let dist = row.distance.unwrap_or_else(u64::max_value);
|
||||||
|
if dist > 5 {
|
||||||
|
println!(
|
||||||
|
"Skipping https://e621.net/post/show/{}, distance too high: {}",
|
||||||
|
row.id, dist
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
println!(
|
println!(
|
||||||
"Possible match: [distance of {}] https://e621.net/post/show/{} by {}",
|
"Possible match: [distance of {}] https://e621.net/post/show/{} by {}",
|
||||||
row.distance.unwrap_or_else(u64::max_value),
|
dist,
|
||||||
row.id,
|
row.id,
|
||||||
row.artists
|
row.artists
|
||||||
.map(|artists| artists.join(", "))
|
.map(|artists| artists.join(", "))
|
||||||
|
@ -63,7 +63,7 @@ async fn main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let max_id: i32 = db
|
let max_id: i32 = db
|
||||||
.query_one("SELECT max(id) FROM post", &[])
|
.query_one("SELECT max(id) FROM e621", &[])
|
||||||
.await
|
.await
|
||||||
.map(|row| row.get("max"))
|
.map(|row| row.get("max"))
|
||||||
.expect("Unable to get max post");
|
.expect("Unable to get max post");
|
||||||
@ -85,7 +85,7 @@ async fn main() {
|
|||||||
min_id = ids.into_iter().min();
|
min_id = ids.into_iter().min();
|
||||||
|
|
||||||
db.execute(
|
db.execute(
|
||||||
"INSERT INTO post (data) SELECT json_array_elements($1::json) ON CONFLICT DO NOTHING",
|
"INSERT INTO e621 (data) SELECT json_array_elements($1::json) ON CONFLICT DO NOTHING",
|
||||||
&[&post_data],
|
&[&post_data],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
Loading…
Reference in New Issue
Block a user