|
|
|
@ -684,17 +684,12 @@ impl QuoteRepository for D1Repository {
|
|
|
|
/// with the given `quote_id` exists.
|
|
|
|
/// with the given `quote_id` exists.
|
|
|
|
async fn create_report(&self, quote_id: &str, reason: Option<&str>) -> Result<(), DbError> {
|
|
|
|
async fn create_report(&self, quote_id: &str, reason: Option<&str>) -> Result<(), DbError> {
|
|
|
|
// Step 1: verify the quote exists.
|
|
|
|
// Step 1: verify the quote exists.
|
|
|
|
#[derive(serde::Deserialize)]
|
|
|
|
|
|
|
|
struct ExistsRow {
|
|
|
|
|
|
|
|
count: i64,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let exists_row = self
|
|
|
|
let exists_row = self
|
|
|
|
.db
|
|
|
|
.db
|
|
|
|
.prepare("SELECT COUNT(*) AS count FROM quotes WHERE id = ?1")
|
|
|
|
.prepare("SELECT COUNT(*) AS count FROM quotes WHERE id = ?1")
|
|
|
|
.bind(&[JsValue::from_str(quote_id)])
|
|
|
|
.bind(&[JsValue::from_str(quote_id)])
|
|
|
|
.map_err(|e| DbError::Internal(e.to_string()))?
|
|
|
|
.map_err(|e| DbError::Internal(e.to_string()))?
|
|
|
|
.first::<ExistsRow>(None)
|
|
|
|
.first::<CountRow>(None)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.map_err(|e| DbError::Internal(e.to_string()))?;
|
|
|
|
.map_err(|e| DbError::Internal(e.to_string()))?;
|
|
|
|
|
|
|
|
|
|
|
|
|