mirror of
https://github.com/Syfaro/fuzzysearch.git
synced 2024-11-23 15:22:31 +00:00
Fix schema name.
This commit is contained in:
parent
880c5f385e
commit
ceeef0b9e9
@ -66,7 +66,7 @@ async fn main() {
|
||||
});
|
||||
|
||||
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
|
||||
@ -84,13 +84,13 @@ async fn main() {
|
||||
.await
|
||||
.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
|
||||
.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
|
||||
.query_one("SELECT MIN(id) FROM post", &[])
|
||||
.query_one("SELECT MIN(id) FROM e621", &[])
|
||||
.await
|
||||
.map(|row| row.get("min"))
|
||||
.expect("Unable to get min post");
|
||||
@ -109,7 +109,7 @@ async fn main() {
|
||||
min_id = ids.into_iter().min();
|
||||
|
||||
db.execute(
|
||||
"INSERT INTO post (data) SELECT json_array_elements($1::json)",
|
||||
"INSERT INTO e621 (data) SELECT json_array_elements($1::json)",
|
||||
&[&post_data],
|
||||
)
|
||||
.await
|
||||
|
@ -45,7 +45,7 @@ async fn load_next_posts(
|
||||
id,
|
||||
data->>'file_url' file_url
|
||||
FROM
|
||||
post
|
||||
e621
|
||||
WHERE
|
||||
hash IS NULL AND
|
||||
hash_error IS NULL AND
|
||||
@ -109,7 +109,7 @@ async fn main() {
|
||||
db.get()
|
||||
.await
|
||||
.unwrap()
|
||||
.execute("UPDATE post SET hash = $2 WHERE id = $1", &[&id, &num])
|
||||
.execute("UPDATE e621 SET hash = $2 WHERE id = $1", &[&id, &num])
|
||||
.await
|
||||
.expect("Unable to update hash in database");
|
||||
}
|
||||
@ -121,7 +121,7 @@ async fn main() {
|
||||
.await
|
||||
.unwrap()
|
||||
.execute(
|
||||
"UPDATE post SET hash_error = $2 WHERE id = $1",
|
||||
"UPDATE e621 SET hash_error = $2 WHERE id = $1",
|
||||
&[&id, &desc],
|
||||
)
|
||||
.await
|
||||
|
@ -58,7 +58,7 @@ async fn main() {
|
||||
artists_agg.artists artists,
|
||||
sources_agg.sources sources
|
||||
FROM
|
||||
post,
|
||||
e621,
|
||||
LATERAL (
|
||||
SELECT array_agg(v) artists FROM jsonb_array_elements_text(data->'artist') v
|
||||
) artists_agg,
|
||||
@ -85,9 +85,17 @@ async fn main() {
|
||||
});
|
||||
|
||||
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!(
|
||||
"Possible match: [distance of {}] https://e621.net/post/show/{} by {}",
|
||||
row.distance.unwrap_or_else(u64::max_value),
|
||||
dist,
|
||||
row.id,
|
||||
row.artists
|
||||
.map(|artists| artists.join(", "))
|
||||
|
@ -63,7 +63,7 @@ async fn main() {
|
||||
});
|
||||
|
||||
let max_id: i32 = db
|
||||
.query_one("SELECT max(id) FROM post", &[])
|
||||
.query_one("SELECT max(id) FROM e621", &[])
|
||||
.await
|
||||
.map(|row| row.get("max"))
|
||||
.expect("Unable to get max post");
|
||||
@ -85,7 +85,7 @@ async fn main() {
|
||||
min_id = ids.into_iter().min();
|
||||
|
||||
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],
|
||||
)
|
||||
.await
|
||||
|
Loading…
Reference in New Issue
Block a user