feat(sentiment): add persistent sentiment entities, summaries, SentimentDbService and MQTT RPC refactoring

This commit is contained in:
2026-08-24 21:35:48 +02:00
parent 600ccf299e
commit 12e7b57b16
24 changed files with 1510 additions and 1300 deletions
@@ -0,0 +1,159 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinlyticSentiment.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "article_sentiments",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ArticleId = table.Column<Guid>(type: "uuid", nullable: false),
Isin = table.Column<string>(type: "character varying(12)", maxLength: 12, nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Sector = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
Label = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
CompoundScore = table.Column<double>(type: "double precision", nullable: false),
Confidence = table.Column<double>(type: "double precision", nullable: false),
Impact = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
PositiveProbability = table.Column<double>(type: "double precision", nullable: false),
NegativeProbability = table.Column<double>(type: "double precision", nullable: false),
NeutralProbability = table.Column<double>(type: "double precision", nullable: false),
KeyHighlight = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
PublishedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
AnalyzedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_article_sentiments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "company_sentiment_summaries",
columns: table => new
{
Isin = table.Column<string>(type: "character varying(12)", maxLength: 12, nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Sector = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
CurrentLabel = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
AverageScore = table.Column<double>(type: "double precision", nullable: false),
WeightedScore = table.Column<double>(type: "double precision", nullable: false),
AverageConfidence = table.Column<double>(type: "double precision", nullable: false),
TotalAnalysesCount = table.Column<int>(type: "integer", nullable: false),
PositiveCount = table.Column<int>(type: "integer", nullable: false),
NegativeCount = table.Column<int>(type: "integer", nullable: false),
NeutralCount = table.Column<int>(type: "integer", nullable: false),
LatestKeyHighlight = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
Trend = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
LastUpdatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Version = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_company_sentiment_summaries", x => x.Isin);
});
migrationBuilder.CreateTable(
name: "DynamicSettings",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Key = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
ValueJson = table.Column<string>(type: "text", nullable: false),
ServiceIdentifier = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
LastUpdatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DynamicSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "sector_sentiment_summaries",
columns: table => new
{
Sector = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
CurrentLabel = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
AverageScore = table.Column<double>(type: "double precision", nullable: false),
TotalArticlesCount = table.Column<int>(type: "integer", nullable: false),
TotalCompaniesCount = table.Column<int>(type: "integer", nullable: false),
LastUpdatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_sector_sentiment_summaries", x => x.Sector);
});
migrationBuilder.CreateIndex(
name: "IX_article_sentiments_AnalyzedAtUtc",
table: "article_sentiments",
column: "AnalyzedAtUtc");
migrationBuilder.CreateIndex(
name: "IX_article_sentiments_ArticleId_Isin",
table: "article_sentiments",
columns: new[] { "ArticleId", "Isin" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_article_sentiments_Isin_PublishedAtUtc",
table: "article_sentiments",
columns: new[] { "Isin", "PublishedAtUtc" });
migrationBuilder.CreateIndex(
name: "IX_article_sentiments_Sector",
table: "article_sentiments",
column: "Sector");
migrationBuilder.CreateIndex(
name: "IX_company_sentiment_summaries_LastUpdatedUtc",
table: "company_sentiment_summaries",
column: "LastUpdatedUtc");
migrationBuilder.CreateIndex(
name: "IX_company_sentiment_summaries_Sector",
table: "company_sentiment_summaries",
column: "Sector");
migrationBuilder.CreateIndex(
name: "IX_company_sentiment_summaries_WeightedScore",
table: "company_sentiment_summaries",
column: "WeightedScore");
migrationBuilder.CreateIndex(
name: "IX_DynamicSettings_Key",
table: "DynamicSettings",
column: "Key",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_sector_sentiment_summaries_LastUpdatedUtc",
table: "sector_sentiment_summaries",
column: "LastUpdatedUtc");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "article_sentiments");
migrationBuilder.DropTable(
name: "company_sentiment_summaries");
migrationBuilder.DropTable(
name: "DynamicSettings");
migrationBuilder.DropTable(
name: "sector_sentiment_summaries");
}
}
}