update code level
This commit is contained in:
@@ -364,27 +364,26 @@ impl Database {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_album_person(&self, album_id: &str, person_name_original: &str, person_name_cleaned: &str) {
|
||||
sqlx::query("UPDATE albums SET person_name_original = ?, person_name_cleaned = ?, processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(person_name_original).bind(person_name_cleaned).bind(album_id).execute(&self.pool).await.ok();
|
||||
pub async fn update_album_person(&self, album_id: &str, _person_name_original: &str, _person_name_cleaned: &str) {
|
||||
sqlx::query("UPDATE albums SET processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(album_id).execute(&self.pool).await.ok();
|
||||
}
|
||||
|
||||
pub async fn update_album_person_with_tx(&self, tx: &mut Transaction<'_, Sqlite>, album_id: &str, person_name_original: &str, person_name_cleaned: &str) {
|
||||
sqlx::query("UPDATE albums SET person_name_original = ?, person_name_cleaned = ?, processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(person_name_original).bind(person_name_cleaned).bind(album_id).execute(tx.deref_mut()).await.ok();
|
||||
pub async fn update_album_person_with_tx(&self, tx: &mut Transaction<'_, Sqlite>, album_id: &str, _person_name_original: &str, _person_name_cleaned: &str) {
|
||||
sqlx::query("UPDATE albums SET processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(album_id).execute(tx.deref_mut()).await.ok();
|
||||
}
|
||||
|
||||
/// 清空该人物所有关联相册的 person 字段(当该人物被确认为非人物后调用)
|
||||
pub async fn update_album_person_by_person_id(&self, person_id: i64) {
|
||||
sqlx::query(
|
||||
"UPDATE albums SET person_name_original = NULL, person_name_cleaned = NULL, \
|
||||
processed_at = datetime('now') WHERE id IN (SELECT album_id FROM person_albums WHERE person_id = ?)"
|
||||
"UPDATE albums SET processed_at = datetime('now') WHERE id IN (SELECT album_id FROM person_albums WHERE person_id = ?)"
|
||||
).bind(person_id).execute(&self.pool).await.ok();
|
||||
}
|
||||
|
||||
pub async fn update_album_tags(&self, album_id: &str, tags_json: &str, all_words_json: &str) {
|
||||
sqlx::query("UPDATE albums SET tags = ?, all_words = ?, processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(tags_json).bind(all_words_json).bind(album_id).execute(&self.pool).await.ok();
|
||||
pub async fn update_album_tags(&self, album_id: &str, tags_json: &str, _all_words_json: &str) {
|
||||
sqlx::query("UPDATE albums SET processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(album_id).execute(&self.pool).await.ok();
|
||||
|
||||
// 用一个事务批量替换 album_tags,避免逐条 autocommit 导致巨慢
|
||||
if let Ok(tags) = serde_json::from_str::<Vec<String>>(tags_json) {
|
||||
@@ -418,9 +417,9 @@ impl Database {
|
||||
}
|
||||
|
||||
/// 与 update_album_tags 相同,但使用已有的事务(不启动内部子事务)
|
||||
pub async fn update_album_tags_with_tx(&self, tx: &mut Transaction<'_, Sqlite>, album_id: &str, tags_json: &str, all_words_json: &str) {
|
||||
sqlx::query("UPDATE albums SET tags = ?, all_words = ?, processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(tags_json).bind(all_words_json).bind(album_id).execute(tx.deref_mut()).await.ok();
|
||||
pub async fn update_album_tags_with_tx(&self, tx: &mut Transaction<'_, Sqlite>, album_id: &str, tags_json: &str, _all_words_json: &str) {
|
||||
sqlx::query("UPDATE albums SET processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(album_id).execute(tx.deref_mut()).await.ok();
|
||||
|
||||
sqlx::query("DELETE FROM album_tags WHERE album_id = ?")
|
||||
.bind(album_id)
|
||||
|
||||
Reference in New Issue
Block a user