-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get it working enough again so lists update n such
- Loading branch information
Showing
16 changed files
with
742 additions
and
630 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// The number of parameters in MySQL must fit in a `u16`. | ||
pub const BIND_LIMIT: usize = 65535; | ||
pub const MYSQL_PARAM_BIND_LIMIT: usize = 65535; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use sqlx::{MySql, Pool, QueryBuilder}; | ||
|
||
pub async fn create_anime_relation( | ||
db: &Pool<MySql>, | ||
items: Vec<(u32, u32, String)>, | ||
) -> Result<(), anyhow::Error> { | ||
if items.is_empty() { | ||
return Ok(()); | ||
} | ||
let mut query_builder = QueryBuilder::new( | ||
r#" | ||
INSERT INTO anime_relations (anime_id, relation_id, relation) | ||
"#, | ||
); | ||
|
||
query_builder.push_values(items.iter(), |mut b, item| { | ||
b.push_bind(item.0) | ||
.push_bind(item.1) | ||
.push_bind(item.2.clone()); | ||
}); | ||
|
||
query_builder.push("ON DUPLICATE KEY UPDATE relation = VALUES(relation)"); | ||
|
||
let q = query_builder.build(); | ||
|
||
q.execute(db).await.expect("Failed to insert anime"); | ||
|
||
tracing::info!("Inserted {} anime relations", items.len()); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod anime; | ||
pub mod anime_relations; | ||
pub mod anime_users; | ||
pub mod user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.