From 232f223f7bdeb69aa093da8a00e7a8779d1b187a Mon Sep 17 00:00:00 2001 From: Andrii Voznesenskyi Date: Mon, 3 Jun 2024 01:11:13 +0200 Subject: [PATCH 1/3] #266 update the notification service add or update asunc method --- .../Mongo/Documents/StudentNotificationsDocument.cs | 4 +--- .../Repositories/StudentNotificationsMongoRepository.cs | 8 ++++---- .../DTO/Notifications/NotificationLinkFactory.cs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Documents/StudentNotificationsDocument.cs b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Documents/StudentNotificationsDocument.cs index 5572bfa8b..75e5f07b3 100644 --- a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Documents/StudentNotificationsDocument.cs +++ b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Documents/StudentNotificationsDocument.cs @@ -9,10 +9,8 @@ namespace MiniSpace.Services.Notifications.Infrastructure.Mongo.Documents public class StudentNotificationsDocument : IIdentifiable { [BsonId] - [BsonRepresentation(BsonType.String)] - public Guid Id { get; set; } - [BsonRepresentation(BsonType.String)] + public Guid Id { get; set; } public Guid StudentId { get; set; } public List Notifications { get; set; } } diff --git a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Repositories/StudentNotificationsMongoRepository.cs b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Repositories/StudentNotificationsMongoRepository.cs index f4f7f9b58..d6c04c05c 100644 --- a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Repositories/StudentNotificationsMongoRepository.cs +++ b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Infrastructure/Mongo/Repositories/StudentNotificationsMongoRepository.cs @@ -65,9 +65,9 @@ public async Task AddOrUpdateAsync(StudentNotifications studentNotifications) var document = studentNotifications.AsDocument(); var filter = Builders.Filter.Eq(doc => doc.StudentId, studentNotifications.StudentId); - // Ensure the document is initialized with an empty list if not present var initializationUpdate = Builders.Update - .SetOnInsert(doc => doc.Notifications, new List()); + .SetOnInsert(doc => doc.Notifications, new List()) + .SetOnInsert(doc => doc.Id, document.Id); var addToSetUpdates = new List>(); foreach (var notification in studentNotifications.Notifications) @@ -86,10 +86,9 @@ public async Task AddOrUpdateAsync(StudentNotifications studentNotifications) } var options = new UpdateOptions { IsUpsert = true }; - // Initialize document if it doesn't exist + await _repository.Collection.UpdateOneAsync(filter, initializationUpdate, options); - // Apply each AddToSet operation foreach (var update in addToSetUpdates) { await _repository.Collection.UpdateOneAsync(filter, update, options); @@ -98,6 +97,7 @@ public async Task AddOrUpdateAsync(StudentNotifications studentNotifications) + public async Task> FindAsync(FilterDefinition filter, FindOptions options) { var documents = await _repository.Collection.Find(filter, options).ToListAsync(); diff --git a/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationLinkFactory.cs b/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationLinkFactory.cs index be07df4b6..f00d6e05b 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationLinkFactory.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationLinkFactory.cs @@ -37,7 +37,7 @@ public static string GetNotificationLink(NotificationDto notification) case NotificationEventType.ReportRejected: case NotificationEventType.ReportResolved: case NotificationEventType.ReportReviewStarted: - return $"/reports/{notification.RelatedEntityId}"; + // return $"/reports/{notification.RelatedEntityId}"; default: return $"/student-details/{notification.RelatedEntityId}"; From 7e7c88195f051dd8c022cb91bd481bb757a8a429 Mon Sep 17 00:00:00 2001 From: Andrii Voznesenskyi Date: Mon, 3 Jun 2024 01:14:48 +0200 Subject: [PATCH 2/3] #266 hot fix deploy --- .github/workflows/cloud_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cloud_deploy.yml b/.github/workflows/cloud_deploy.yml index 787a40b66..f74df033e 100644 --- a/.github/workflows/cloud_deploy.yml +++ b/.github/workflows/cloud_deploy.yml @@ -3,10 +3,10 @@ name: Deploy to Cloud on: push: branches: - - main + - dev pull_request: branches: - - main + - dev jobs: deploy: From 0b00c07e1764ad7902928ee77620f444e965c4e0 Mon Sep 17 00:00:00 2001 From: Andrii Voznesenskyi Date: Mon, 3 Jun 2024 01:26:02 +0200 Subject: [PATCH 3/3] #266 update deployment script to make deployment from main only --- .github/workflows/cloud_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cloud_deploy.yml b/.github/workflows/cloud_deploy.yml index f74df033e..787a40b66 100644 --- a/.github/workflows/cloud_deploy.yml +++ b/.github/workflows/cloud_deploy.yml @@ -3,10 +3,10 @@ name: Deploy to Cloud on: push: branches: - - dev + - main pull_request: branches: - - dev + - main jobs: deploy: