Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions crates/buzz-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 20 additions & 1 deletion crates/buzz-db/src/product_feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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::*;
Expand Down
Loading