feat(migrations): Harden task audit tracking and optimize article templates

- Added migration to harden task audit tracking by modifying audit_logs and related tables.
- Introduced operator_id to several tables for better tracking of actions.
- Updated article_templates with new prompt templates for various article types, enhancing content generation.
- Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling.
- Added foreign key constraints to articles for better data integrity.
This commit is contained in:
2026-04-02 00:31:28 +08:00
parent de30497f59
commit b31d8d0096
101 changed files with 16671 additions and 721 deletions
@@ -4,6 +4,9 @@ import (
"context"
"time"
"github.com/jackc/pgx/v5/pgtype"
"github.com/geo-platform/tenant-api/internal/shared/contentstats"
"github.com/geo-platform/tenant-api/internal/tenant/repository/generated"
)
@@ -71,7 +74,7 @@ func (r *workspaceRepository) GetRecentArticles(ctx context.Context, tenantID in
SourceType: row.SourceType,
CreatedAt: timeFromTimestamp(row.CreatedAt),
Title: nullableText(row.Title),
WordCount: intFromInt4(row.WordCount),
WordCount: resolveWorkspaceWordCount(row.MarkdownContent, intFromInt4(row.WordCount)),
SourceLabel: nullableText(row.SourceLabel),
TemplateName: nullableText(row.TemplateName),
})
@@ -102,3 +105,12 @@ func (r *workspaceRepository) GetActivePlanForTenant(ctx context.Context, tenant
EndAt: timeFromTimestamp(row.EndAt),
}, nil
}
func resolveWorkspaceWordCount(markdown pgtype.Text, stored int) int {
if markdown.Valid {
if counted := contentstats.CountWords(markdown.String); counted > 0 {
return counted
}
}
return stored
}