feature/insight-jobs #102
@@ -161,13 +161,13 @@ impl InsightDao for SqliteInsightDao {
|
||||
)
|
||||
.set(is_current.eq(false))
|
||||
.execute(connection.deref_mut())
|
||||
.map_err(|_| anyhow::anyhow!("Update is_current error"))?;
|
||||
.map_err(|e| anyhow::anyhow!("Failed to flip is_current: {}", e))?;
|
||||
|
||||
// Insert the new insight as current
|
||||
diesel::insert_into(photo_insights)
|
||||
.values(&insight)
|
||||
.execute(connection.deref_mut())
|
||||
.map_err(|_| anyhow::anyhow!("Insert error"))?;
|
||||
.map_err(|e| anyhow::anyhow!("Failed to insert insight: {}", e))?;
|
||||
|
||||
// Retrieve the inserted record (is_current = true)
|
||||
photo_insights
|
||||
@@ -175,9 +175,12 @@ impl InsightDao for SqliteInsightDao {
|
||||
.filter(rel_path.eq(&insight.file_path))
|
||||
.filter(is_current.eq(true))
|
||||
.first::<PhotoInsight>(connection.deref_mut())
|
||||
.map_err(|_| anyhow::anyhow!("Query error"))
|
||||
.map_err(|e| anyhow::anyhow!("Failed to retrieve inserted insight: {}", e))
|
||||
})
|
||||
.map_err(|e| {
|
||||
log::error!("store_insight failed: {}", e);
|
||||
DbError::new(DbErrorKind::InsertError)
|
||||
})
|
||||
.map_err(|_| DbError::new(DbErrorKind::InsertError))
|
||||
}
|
||||
|
||||
fn get_insight(
|
||||
|
||||
Reference in New Issue
Block a user