refactor(db): move product feedback store ownership

Signed-off-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
OpenAI Codex
2026-08-26 14:53:49 +00:00
committed by Luke Tornquist
parent eacd5739e6
commit 512857fe1d
2 changed files with 20 additions and 20 deletions

View File

@@ -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(

View File

@@ -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::*;