naco-api/internal/store/GetStyleProfile.sql.go
Nacorid 0dcb74675e fix(analytics,x402): fix coverage gaps, engagement drivers, and Twitter cost passing
Analytics review fixes:
- Store Twitter analytics coverage as discrete intervals instead of a single
  contiguous window so disjoint fetch ranges no longer mask inner gaps as
  covered (fetch per uncovered range, add gap regression tests)
- Compute real AvgEngagement/Correlation in getEngagementDrivers instead of
  all-zero placeholders
- Make parseAnalyticsTimeRange surface invalid timestamps, cap merged analytics
  posts at limit, and normalize sentiment by timestamped posts only
- gofmt: fix misalignment in config.go and types.go
- Include Twitter in the default aggregate analytics scope; its API costs are
  passed to the caller through paid tool pricing

x402 cost passing:
- computeTwitterStyleProfileCost now charges base cost ($0.10) + user lookup
  ($0.01) + $0.005 per Twitter post, guaranteeing the charge always clears the
  underlying API cost (never break-even or loss)
- Return a $-prefixed dollar string for the settlement override, fixing the
  previously off-by-factor-100 raw-atomic-unit amount
- Raise getStyleProfile base registration to $0.36 to authorize the max Twitter
  charge
- Add tests for the cost formula, profitable floor, and dollar formatting
2026-09-02 22:44:02 +00:00

42 lines
972 B
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: GetStyleProfile.sql
package store
import (
"context"
"github.com/lib/pq"
)
const getStyleProfile = `-- name: GetStyleProfile :one
SELECT id, user_id, platform, embedding, top_keywords, style_summary, post_count, modified_at, created_at, model_version, schema_version, algorithm_version FROM user_style_profiles
WHERE user_id = $1 AND platform = $2
`
type GetStyleProfileParams struct {
UserID string
Platform string
}
func (q *Queries) GetStyleProfile(ctx context.Context, arg GetStyleProfileParams) (UserStyleProfile, error) {
row := q.db.QueryRowContext(ctx, getStyleProfile, arg.UserID, arg.Platform)
var i UserStyleProfile
err := row.Scan(
&i.ID,
&i.UserID,
&i.Platform,
&i.Embedding,
pq.Array(&i.TopKeywords),
&i.StyleSummary,
&i.PostCount,
&i.ModifiedAt,
&i.CreatedAt,
&i.ModelVersion,
&i.SchemaVersion,
&i.AlgorithmVersion,
)
return i, err
}