Commit graph naco-api/sql
Author SHA1 Message Date
8c561a83a2
chore: idempotent migrations (IF NOT EXISTS) + systemd binary name fix 2026-09-08 01:31:50 +00:00
57a9c43890
fix: interface{} -> any, +goose up -> +goose up
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 3m52s
CI/CD Go Verification / build_and_test (push) Successful in 1m21s
2026-09-05 01:01:07 +00:00
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
c851d0e50f store: add sqlc queries for analytics cache, posts and coverage 2026-09-02 23:49:35 +02:00
ab1eb634f9 schema: add analytics cache, posts and coverage tables
Add tables backing the analytics cache, the permanent per-platform post
store, and the coverage watermark used to avoid re-fetching paid Twitter
posts once a time range has already been retrieved.
2026-09-02 23:49:32 +02:00
5574a8596f db: update embedding dimension to 1024 for qwen3-embedding:0.6b
- Migration 002: VECTOR(768) -> VECTOR(1024) to match qwen3-embedding:0.6b default output
- integration_test.go: update test vector from 768 to 1024 dimensions
2026-09-02 00:00:10 +02:00
63709524de db: make migrations idempotent, regenerate store, minor cleanup
- schema: add IF NOT EXISTS to CREATE TABLE/INDEX for idempotent migrations
- store: regenerate with sqlc v1.31.1 (adds UserStylePost, interface{} for Embedding)
- webhook: minor formatting cleanup
2026-09-01 23:42:23 +02:00
63f8756cc7 db: add user_style_posts table for post ID caching
- migration 004: create user_style_posts with user_id, platform, post_id, post_text, created_at
- queries: UpsertStylePosts, DeleteStylePosts (excludes Twitter), GetStylePosts, GetStylePostsByIDs, GetStylePostByID, PruneStylePosts
- activitypub: add ID field to Post struct
- server: fetchProfilePosts checks cache first, upserts on miss; buildStyleProfile deletes non-Twitter posts before rebuild; background pruner runs daily
2026-09-01 23:41:45 +02:00
d7bece250f Use named parameters in SQL queries to avoid ColumnN naming in sqlc generated structs
- Rewrite GetStyleProfile, FindSimilarUsers, UpsertStyleProfiles SQL queries
  to use @named parameters instead of  positional placeholders
- Regenerate sqlc Go files with meaningful parameter names
- Update server.go and integration test to use new parameter field names
- Fix Similarity int32→float64 type conversion
2026-08-30 22:41:53 +02:00
bd707cf2ca refactor: replace interface{} with any
- convert remaining interface{} usages to any in store, utils, bluesky
- consolidate pgvector extension drop into 002 migration
2026-08-30 16:03:03 +02:00
8cfb1291aa ops: migrator, enrichment backpressure, ollama fallback, readiness
- Add dependency-free in-process schema migrator (internal/store/migrate.go) that applies
  sql/schema/*.sql in order, tracking versions in schema_migrations. Gated by MIGRATE_ON_START
  and MIGRATIONS_DIR (default sql/schema).
- Fix migration ordering: 002 now creates the 'vector' extension before defining the
  user_style_profiles table (previously the extension was only created later in 003).
- Bound concurrent background enrichment with a 4-slot semaphore so bursts of live
  getStyleProfile calls cannot overwhelm Ollama.
- buildStyleProfile degrades gracefully when Ollama is down: stores a zero embedding and a
  keyword-based fallback summary instead of failing the whole request.
- Add a /readyz side server (READYZ_PORT, default 9090) that checks DB connectivity and
  Ollama availability.

Co-Authored-By: Claude (AI assistant) <noreply@anthropic.com>
2026-08-29 02:09:50 +02:00
12bf3e8311 add: make getStyleProfile work (embeddings, platform gating, pgvector extension) 2026-08-29 00:32:50 +02:00
b87910d1c4 Major changes 2025-12-02 19:33:03 +00:00
af58fdeeab initial commit 2025-10-25 01:06:02 +00:00