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
21 lines
911 B
SQL
21 lines
911 B
SQL
-- +goose up
|
|
-- Tracks which time ranges have already been fetched for an author on a
|
|
-- platform so paid API calls (e.g. Twitter) are not repeated. Coverage is
|
|
-- stored as discrete non-overlapping intervals rather than a single
|
|
-- contiguous window, so gaps between separately-fetched ranges are not
|
|
-- mistaken for covered data.
|
|
CREATE TABLE IF NOT EXISTS analytics_coverage_ranges (
|
|
user_id TEXT NOT NULL,
|
|
platform TEXT NOT NULL,
|
|
covered_start TIMESTAMPTZ NOT NULL,
|
|
covered_end TIMESTAMPTZ NOT NULL,
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (user_id, platform, covered_start, covered_end)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_analytics_coverage_ranges_lookup
|
|
ON analytics_coverage_ranges (user_id, platform, covered_start);
|
|
|
|
-- +goose down
|
|
DROP INDEX IF EXISTS idx_analytics_coverage_ranges_lookup;
|
|
DROP TABLE IF EXISTS analytics_coverage_ranges;
|