36451a613d
- Added comprehensive technical design document for AI Brand Monitoring System V5, outlining system architecture, data models, sampling strategies, and monitoring protocols. - Key changes include a shift to a sampling-based trend monitoring approach, updated data collection and storage strategies, and new metrics for performance evaluation. - Implemented migration scripts to support the flattening of brand questions and versioning of question texts, ensuring historical data integrity and version control.
81 lines
1.4 KiB
Go
81 lines
1.4 KiB
Go
package repository
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"github.com/geo-platform/tenant-api/internal/tenant/repository/generated"
|
|
)
|
|
|
|
func newQuerier(db generated.DBTX) generated.Querier {
|
|
return generated.New(db)
|
|
}
|
|
|
|
func nullableText(value pgtype.Text) *string {
|
|
if !value.Valid {
|
|
return nil
|
|
}
|
|
text := value.String
|
|
return &text
|
|
}
|
|
|
|
func nullableAnyText(value interface{}) *string {
|
|
switch typed := value.(type) {
|
|
case nil:
|
|
return nil
|
|
case string:
|
|
return &typed
|
|
case []byte:
|
|
text := string(typed)
|
|
return &text
|
|
case pgtype.Text:
|
|
return nullableText(typed)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func nullableInt64(value pgtype.Int8) *int64 {
|
|
if !value.Valid {
|
|
return nil
|
|
}
|
|
number := value.Int64
|
|
return &number
|
|
}
|
|
|
|
func intFromInt4(value pgtype.Int4) int {
|
|
if !value.Valid {
|
|
return 0
|
|
}
|
|
return int(value.Int32)
|
|
}
|
|
|
|
func timeFromTimestamp(value pgtype.Timestamptz) time.Time {
|
|
if !value.Valid {
|
|
return time.Time{}
|
|
}
|
|
return value.Time
|
|
}
|
|
|
|
func pgText(value *string) pgtype.Text {
|
|
if value == nil {
|
|
return pgtype.Text{}
|
|
}
|
|
return pgtype.Text{String: *value, Valid: true}
|
|
}
|
|
|
|
func pgInt8(value *int64) pgtype.Int8 {
|
|
if value == nil {
|
|
return pgtype.Int8{}
|
|
}
|
|
return pgtype.Int8{Int64: *value, Valid: true}
|
|
}
|
|
|
|
func pgTimestamp(value *time.Time) pgtype.Timestamptz {
|
|
if value == nil {
|
|
return pgtype.Timestamptz{}
|
|
}
|
|
return pgtype.Timestamptz{Time: *value, Valid: true}
|
|
}
|