mirror of
https://github.com/block/buzz.git
synced 2026-10-30 14:01:37 +00:00
refactor(db): move product feedback store ownership
Signed-off-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
committed by
Luke Tornquist
parent
eacd5739e6
commit
512857fe1d
@@ -1335,25 +1335,6 @@ impl Db {
|
||||
Ok(result.rows_affected())
|
||||
}
|
||||
|
||||
/// Sidecar an accepted product-feedback event, idempotent by event id.
|
||||
#[datastore_span(name = "insert_product_feedback", system = "postgresql")]
|
||||
pub async fn insert_product_feedback(
|
||||
&self,
|
||||
community: CommunityId,
|
||||
feedback: product_feedback::NewProductFeedback<'_>,
|
||||
) -> Result<Uuid> {
|
||||
product_feedback::insert(&self.pool, community, feedback).await
|
||||
}
|
||||
|
||||
/// List product feedback across the deployment, newest first.
|
||||
#[datastore_span(name = "list_product_feedback", system = "postgresql")]
|
||||
pub async fn list_product_feedback(
|
||||
&self,
|
||||
limit: i64,
|
||||
) -> Result<Vec<product_feedback::ProductFeedbackRecord>> {
|
||||
product_feedback::list(&self.pool, limit).await
|
||||
}
|
||||
|
||||
/// Insert a tenant-scoped NIP-56 report row, idempotent by report event id.
|
||||
#[datastore_span(name = "insert_moderation_report", system = "postgresql")]
|
||||
pub async fn insert_moderation_report(
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
//! Feedback retains its source [`CommunityId`] as provenance, but is not a
|
||||
//! community moderation concern and is never inserted into the events table.
|
||||
|
||||
use buzz_datastore_tracing::datastore_span;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
use sqlx::{PgPool, Row as _};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{error::Result, CommunityId};
|
||||
use crate::{error::Result, CommunityId, Db};
|
||||
|
||||
/// Validated fields from an accepted product-feedback event.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -117,6 +118,24 @@ pub async fn list(pool: &PgPool, limit: i64) -> Result<Vec<ProductFeedbackRecord
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl Db {
|
||||
/// Sidecar an accepted product-feedback event, idempotent by event id.
|
||||
#[datastore_span(name = "insert_product_feedback", system = "postgresql")]
|
||||
pub async fn insert_product_feedback(
|
||||
&self,
|
||||
community: CommunityId,
|
||||
feedback: NewProductFeedback<'_>,
|
||||
) -> Result<Uuid> {
|
||||
insert(&self.pool, community, feedback).await
|
||||
}
|
||||
|
||||
/// List product feedback across the deployment, newest first.
|
||||
#[datastore_span(name = "list_product_feedback", system = "postgresql")]
|
||||
pub async fn list_product_feedback(&self, limit: i64) -> Result<Vec<ProductFeedbackRecord>> {
|
||||
list(&self.pool, limit).await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user