diff --git a/.github/chore/compose.content.yaml b/.github/chore/compose.content.yaml index 0ab3622c..61d1f110 100644 --- a/.github/chore/compose.content.yaml +++ b/.github/chore/compose.content.yaml @@ -29,7 +29,7 @@ services: timeout: 20s retries: 10 redis: - image: redis:7.2.3-alpine3.18 + image: valkey/valkey:7.2.7-alpine3.20 ports: - 6379:6379 volumes: @@ -41,7 +41,7 @@ services: - 50051:50051 - 8088:8088 depends_on: - mysql: + postgres: condition: service_healthy db1: condition: service_healthy @@ -52,20 +52,19 @@ services: image: sixwaaaay/graph:v0.5.0 ports: - 8080:8080 - mysql: - image: mysql:8.2.0 + postgres: + image: postgres:17.0-bookworm environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: content - MYSQL_USER: mysql_user - MYSQL_PASSWORD: mysql + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres ports: - - 33306:3306 + - 5432:5432 volumes: - ./content.sql:/docker-entrypoint-initdb.d/content.sql - - mysql-data:/var/lib/mysql + - postgres-data:/var/lib/postgresql/data healthcheck: - test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] + test: [ "CMD", "pg_isready", "-U", "postgres" ] timeout: 20s retries: 10 jaeger: @@ -75,6 +74,6 @@ services: - 16686:16686 volumes: - mysql-data: + postgres-data: redis-data: db1-data: \ No newline at end of file diff --git a/.github/chore/content.sql b/.github/chore/content.sql index 8e17cbe5..f90a545b 100644 --- a/.github/chore/content.sql +++ b/.github/chore/content.sql @@ -12,107 +12,96 @@ */ -CREATE TABLE `notifications` +CREATE TABLE notifications ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `sender_id` BIGINT NOT NULL, - `receiver_id` BIGINT NOT NULL, - `content` varchar(255) NOT NULL, - `type` TINYINT unsigned NOT NULL DEFAULT 0, - `status` TINYINT unsigned NOT NULL DEFAULT 0, - `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `query_by_receiver_id` (`status`,`receiver_id`,`id` ASC) -) ENGINE=InnoDB - DEFAULT CHARSET=utf8mb4 - COLLATE=utf8mb4_0900_ai_ci; + id BIGSERIAL PRIMARY KEY, + sender_id BIGINT NOT NULL, + receiver_id BIGINT NOT NULL, + content VARCHAR(255) NOT NULL, + type SMALLINT NOT NULL DEFAULT 0, + status SMALLINT NOT NULL DEFAULT 0, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + + +CREATE INDEX query_by_receiver_id + ON notifications (status, receiver_id, id ASC); CREATE TABLE videos ( - id BIGINT NOT NULL AUTO_INCREMENT, + id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, title VARCHAR(255) NOT NULL, des VARCHAR(255) NOT NULL, - cover_url VARCHAR(255) NOT NULL default '', - video_url VARCHAR(255) NOT NULL default '', - duration INT UNSIGNED, - view_count INT UNSIGNED NOT NULL DEFAULT 0, - like_count INT UNSIGNED NOT NULL DEFAULT 0, + cover_url VARCHAR(255) NOT NULL DEFAULT '', + video_url VARCHAR(255) NOT NULL DEFAULT '', + duration INTEGER NOT NULL DEFAULT 0, + view_count INTEGER NOT NULL DEFAULT 0, + like_count INTEGER NOT NULL DEFAULT 0, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - processed TINYINT NOT NULL DEFAULT 0, - PRIMARY KEY (id), - KEY `user_created` (`processed`, `user_id`, `id` DESC), - KEY `processed` (`processed`, `id` DESC) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_unicode_ci; + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + processed SMALLINT NOT NULL DEFAULT 0 +); -CREATE TABLE counter -( - id BIGINT NOT NULL, - counter INT UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY (id) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_unicode_ci; -INSERT INTO content.videos (id, user_id, title, des, cover_url, video_url, duration, view_count, like_count, created_at, updated_at, processed) -VALUES (1, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:12:27', '2023-12-31 01:12:27', 1), - (2, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:02', '2023-12-31 01:13:02', 1), - (3, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:19', '2023-12-31 01:13:19', 1), - (4, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:14:18', '2023-12-31 01:14:18', 1), - (5, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:07', '2023-12-31 12:05:07', 1), - (6, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:23', '2023-12-31 12:05:23', 1), - (7, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:42:53', '2023-12-31 12:42:53', 1), - (8, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:43:40', '2023-12-31 12:43:40', 1), - (9, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:18', '2023-12-31 12:53:18', 1), - (10, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:58', '2023-12-31 12:53:58', 1), - (11, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:08:05', '2023-12-31 13:08:05', 1), - (12, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:55:52', '2023-12-31 13:55:52', 1), - (13, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:56:22', '2023-12-31 13:56:22', 1), - (14, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:01:47', '2023-12-31 14:01:47', 1), - (15, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:10', '2023-12-31 14:02:10', 1), - (16, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:22', '2023-12-31 14:02:22', 1), - (17, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:42', '2023-12-31 14:02:42', 1), - (18, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:08:44', '2023-12-31 14:08:44', 1), - (19, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:09:13', '2023-12-31 14:09:13', 1), - (20, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:04', '2023-12-31 14:10:04', 1), - (21, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:48', '2023-12-31 14:10:48', 1), - (22, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:17:40', '2023-12-31 14:17:40', 1), - (23, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:32:50', '2023-12-31 14:32:50', 1), - (24, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:33:19', '2023-12-31 14:33:19', 1), - (25, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:41:41', '2023-12-31 14:41:41', 1), - (26, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:46:15', '2023-12-31 14:46:15', 1), - (27, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 22:03:32', '2023-12-31 22:03:32', 1), - (28, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:22:43', '2023-12-31 23:22:43', 1), - (29, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:23:05', '2023-12-31 23:23:05', 1), - (30, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:55:59', '2023-12-31 23:55:59', 1), - (31, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:51:46', '2024-01-01 14:51:46', 1), - (32, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:38', '2024-01-01 14:52:38', 1), - (33, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:49', '2024-01-01 14:52:49', 1), - (34, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:53:01', '2024-01-01 14:53:01', 1), - (35, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 15:10:38', '2024-01-01 15:10:38', 1), - (36, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 19:51:31', '2024-01-01 19:51:31', 1), - (37, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:15:07', '2024-01-01 20:15:07', 1), - (38, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:17:29', '2024-01-01 20:17:29', 1), - (39, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:11:43', '2024-01-02 14:11:43', 1), - (40, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:12:04', '2024-01-02 14:12:04', 1), - (41, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 15:36:48', '2024-01-02 15:36:48', 1); +CREATE INDEX user_created + ON videos (processed, user_id, id DESC); +CREATE INDEX processed + ON videos (processed, id DESC); + -INSERT INTO content.counter (id, counter) -SELECT videos.user_id, count(*) FROM videos GROUP BY videos.user_id; +INSERT INTO videos (user_id, title, des, cover_url, video_url, duration, view_count, like_count, created_at, updated_at, processed) +VALUES (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:12:27', '2023-12-31 01:12:27', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:02', '2023-12-31 01:13:02', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:19', '2023-12-31 01:13:19', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:14:18', '2023-12-31 01:14:18', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:07', '2023-12-31 12:05:07', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:23', '2023-12-31 12:05:23', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:42:53', '2023-12-31 12:42:53', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:43:40', '2023-12-31 12:43:40', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:18', '2023-12-31 12:53:18', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:58', '2023-12-31 12:53:58', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:08:05', '2023-12-31 13:08:05', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:55:52', '2023-12-31 13:55:52', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:56:22', '2023-12-31 13:56:22', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:01:47', '2023-12-31 14:01:47', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:10', '2023-12-31 14:02:10', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:22', '2023-12-31 14:02:22', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:42', '2023-12-31 14:02:42', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:08:44', '2023-12-31 14:08:44', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:09:13', '2023-12-31 14:09:13', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:04', '2023-12-31 14:10:04', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:48', '2023-12-31 14:10:48', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:17:40', '2023-12-31 14:17:40', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:32:50', '2023-12-31 14:32:50', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:33:19', '2023-12-31 14:33:19', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:41:41', '2023-12-31 14:41:41', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:46:15', '2023-12-31 14:46:15', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 22:03:32', '2023-12-31 22:03:32', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:22:43', '2023-12-31 23:22:43', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:23:05', '2023-12-31 23:23:05', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:55:59', '2023-12-31 23:55:59', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:51:46', '2024-01-01 14:51:46', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:38', '2024-01-01 14:52:38', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:49', '2024-01-01 14:52:49', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:53:01', '2024-01-01 14:53:01', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 15:10:38', '2024-01-01 15:10:38', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 19:51:31', '2024-01-01 19:51:31', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:15:07', '2024-01-01 20:15:07', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:17:29', '2024-01-01 20:17:29', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:11:43', '2024-01-02 14:11:43', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:12:04', '2024-01-02 14:12:04', 1), + (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 15:36:48', '2024-01-02 15:36:48', 1); CREATE TABLE popular_videos ( - order_num BIGINT NOT NULL + id BIGINT NOT NULL PRIMARY KEY, - id BIGINT NULL, - score DOUBLE NULL + order_num BIGINT NOT NULL, + score DOUBLE PRECISION NULL ); - INSERT INTO popular_videos (id, order_num, score) VALUES ('16', 1, 90.077423201946), ('38', 2, 89.7837850170059), diff --git a/.github/workflows/content.yaml b/.github/workflows/content.yaml index ec1da3fb..aa08fd7c 100644 --- a/.github/workflows/content.yaml +++ b/.github/workflows/content.yaml @@ -59,7 +59,7 @@ jobs: dotnet test --collect "Code Coverage;Format=cobertura" dotnet-coverage merge -o merged.cobertura.xml -f cobertura TestResults/**/*.cobertura.xml env: - CONNECTION_STRING: "server=localhost;port=33306;database=content;user=mysql_user;password=mysql;SslMode=none;Max Pool Size=2;AllowPublicKeyRetrieval=True; " + CONNECTION_STRING: "Host=localhost; Port=5432; Username=postgres; Password=postgres; Database=postgres; Maximum Pool Size=25;" USER_STRING: "http://localhost:50051" VOTE_STRING: "http://localhost:8080" FFPROBE_PATH: "/usr/bin/ffprobe" diff --git a/sharp/content.Tests/UnitTest.cs b/sharp/content.Tests/UnitTest.cs index 2cbd9828..575ae4d5 100644 --- a/sharp/content.Tests/UnitTest.cs +++ b/sharp/content.Tests/UnitTest.cs @@ -14,7 +14,7 @@ using content.repository; using JetBrains.Annotations; -using MySqlConnector; +using Npgsql; using Xunit.Abstractions; namespace content.Tests; @@ -27,7 +27,7 @@ public class UnitTest(ITestOutputHelper testOutputHelper) [Fact(DisplayName = "Video Repository")] public async void Test1() { - await using var dataSource = new MySqlDataSource(_connectString); + await using var dataSource = NpgsqlDataSource.Create(_connectString); var videoRepository = (IVideoRepository)new VideoRepository(dataSource); var video = new Video { @@ -40,8 +40,8 @@ public async void Test1() Duration = 1, ViewCount = 1, LikeCount = 1, - CreatedAt = DateTime.Now, - UpdatedAt = DateTime.Now, + CreatedAt = DateTime.UtcNow, + UpdatedAt = DateTime.UtcNow, Processed = 1 }; video = await videoRepository.Save(video); @@ -79,7 +79,7 @@ public async void Test1() [Fact(DisplayName = "Command")] public async void TestInsert() { - await using var dataSource = new MySqlDataSource(_connectString); + await using var dataSource = NpgsqlDataSource.Create(_connectString); var videoRepository = (IVideoRepository)new VideoRepository(dataSource); var video = new Video { @@ -92,8 +92,8 @@ public async void TestInsert() Duration = 1, ViewCount = 1, LikeCount = 1, - CreatedAt = DateTime.Now, - UpdatedAt = DateTime.Now, + CreatedAt = DateTime.UtcNow, + UpdatedAt = DateTime.UtcNow, Processed = 1 }; video = await videoRepository.Save(video); @@ -105,7 +105,7 @@ public async Task Test3() { var now = DateTime.Now; var tasks = new List(); - await using var dataSource = new MySqlDataSource(_connectString); + await using var dataSource = NpgsqlDataSource.Create(_connectString); for (var i = 0; i < 10000; i++) { var videoRepository = new VideoRepository(dataSource); diff --git a/sharp/content.Tests/repository/NotificationRepositoryTest.cs b/sharp/content.Tests/repository/NotificationRepositoryTest.cs index 53e2230e..5207e2eb 100644 --- a/sharp/content.Tests/repository/NotificationRepositoryTest.cs +++ b/sharp/content.Tests/repository/NotificationRepositoryTest.cs @@ -13,8 +13,8 @@ */ -using MySqlConnector; using content.repository; +using Npgsql; namespace content.Tests.repository; public class NotificationRepositoryTests @@ -23,7 +23,7 @@ public class NotificationRepositoryTests public NotificationRepositoryTests() { - var dataSource = new MySqlDataSource(Environment.GetEnvironmentVariable("CONNECTION_STRING") !); + var dataSource = NpgsqlDataSource.Create(Environment.GetEnvironmentVariable("CONNECTION_STRING") !); _repository = new NotificationRepository(dataSource); } diff --git a/sharp/content/Program.cs b/sharp/content/Program.cs index 928cdd53..a6d84a04 100644 --- a/sharp/content/Program.cs +++ b/sharp/content/Program.cs @@ -20,7 +20,7 @@ using content.repository; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; -using MySqlConnector; +using Npgsql; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -51,7 +51,7 @@ builder.Services.AddOpenTelemetry().WithTracing(tcb => { tcb - .AddSource(serviceName).AddSource("MySqlConnector") + .AddSource(serviceName).AddNpgsql() .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName: serviceName)) .AddHttpClientInstrumentation() .AddGrpcClientInstrumentation() @@ -66,7 +66,7 @@ }).WithMetrics(mtb => { mtb - .AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "MySqlConnector") + .AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "Npgsql") .AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddPrometheusExporter(); @@ -78,7 +78,7 @@ builder.Services.AddAuthorization().AddProbe(); builder.Services.AddProblemDetails().AddResponseCompression(); -builder.Services.AddMySqlDataSource(builder.Configuration.GetConnectionString("Default") ?? +builder.Services.AddNpgsqlDataSource(builder.Configuration.GetConnectionString("Default") ?? throw new InvalidOperationException("Connection string is null")); builder.Services.AddVideoRepository().AddNotificationRepository(); diff --git a/sharp/content/content.csproj b/sharp/content/content.csproj index ab25e8f5..7547978e 100644 --- a/sharp/content/content.csproj +++ b/sharp/content/content.csproj @@ -40,8 +40,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + + diff --git a/sharp/content/repository/Content.cs b/sharp/content/repository/Content.cs index db70bca6..fd576036 100644 --- a/sharp/content/repository/Content.cs +++ b/sharp/content/repository/Content.cs @@ -13,7 +13,7 @@ */ using Dapper; -using MySqlConnector; +using Npgsql; [module: DapperAot] @@ -29,7 +29,6 @@ public record Video public string CoverUrl { get; init; } = string.Empty; - public string VideoUrl { get; init; } = string.Empty; public int Duration { get; init; } @@ -38,9 +37,9 @@ public record Video public int LikeCount { get; init; } - public DateTime CreatedAt { get; init; } = DateTime.Now; // todo + public DateTime CreatedAt { get; init; } = DateTime.UtcNow; - public DateTime UpdatedAt { get; init; } = DateTime.Now; // todo + public DateTime UpdatedAt { get; init; } = DateTime.UtcNow; public short Processed { get; init; } = 1; } @@ -55,7 +54,7 @@ public interface IVideoRepository Task