feat: implement article version content storage and reconstruction logic; enhance article repository with version management
This commit is contained in:
@@ -4,9 +4,6 @@ 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"
|
||||
)
|
||||
|
||||
@@ -76,7 +73,7 @@ func (r *workspaceRepository) GetRecentArticles(ctx context.Context, tenantID in
|
||||
GenerationMode: nullableText(row.GenerationMode),
|
||||
CreatedAt: timeFromTimestamp(row.CreatedAt),
|
||||
Title: nullableText(row.Title),
|
||||
WordCount: resolveWorkspaceWordCount(row.MarkdownContent, intFromInt4(row.WordCount)),
|
||||
WordCount: intFromInt4(row.WordCount),
|
||||
SourceLabel: nullableText(row.SourceLabel),
|
||||
TemplateName: nullableText(row.TemplateName),
|
||||
})
|
||||
@@ -107,12 +104,3 @@ 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user