Skip to content

Commit

Permalink
Merge pull request #268 from SaintAngeLs/dev
Browse files Browse the repository at this point in the history
(#266) hot fix notification service update
  • Loading branch information
SaintAngeLs authored Jun 2, 2024
2 parents 37e6be1 + 253d6dc commit 049eaa0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ namespace MiniSpace.Services.Notifications.Infrastructure.Mongo.Documents
public class StudentNotificationsDocument : IIdentifiable<Guid>
{
[BsonId]
[BsonRepresentation(BsonType.String)]
public Guid Id { get; set; }

[BsonRepresentation(BsonType.String)]
public Guid Id { get; set; }
public Guid StudentId { get; set; }
public List<NotificationDocument> Notifications { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public async Task AddOrUpdateAsync(StudentNotifications studentNotifications)
var document = studentNotifications.AsDocument();
var filter = Builders<StudentNotificationsDocument>.Filter.Eq(doc => doc.StudentId, studentNotifications.StudentId);

// Ensure the document is initialized with an empty list if not present
var initializationUpdate = Builders<StudentNotificationsDocument>.Update
.SetOnInsert(doc => doc.Notifications, new List<NotificationDocument>());
.SetOnInsert(doc => doc.Notifications, new List<NotificationDocument>())
.SetOnInsert(doc => doc.Id, document.Id);

var addToSetUpdates = new List<UpdateDefinition<StudentNotificationsDocument>>();
foreach (var notification in studentNotifications.Notifications)
Expand All @@ -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);
Expand All @@ -98,6 +97,7 @@ public async Task AddOrUpdateAsync(StudentNotifications studentNotifications)




public async Task<List<StudentNotifications>> FindAsync(FilterDefinition<StudentNotificationsDocument> filter, FindOptions options)
{
var documents = await _repository.Collection.Find(filter, options).ToListAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down

0 comments on commit 049eaa0

Please sign in to comment.