diff --git a/.drone.yml b/.drone.yml index 4baabb0..d5b9121 100644 --- a/.drone.yml +++ b/.drone.yml @@ -41,7 +41,7 @@ steps: \"tag_name\": \"$VERSION\", \"target_commitish\": \"${DRONE_COMMIT_SHA}\", \"name\": \"Library Suite $VERSION\", - \"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Abstractions\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\", + \"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\", \"draft\": false, \"prerelease\": false }" diff --git a/LiteCharms.Features/Quartz/JobOrchestrator.cs b/LiteCharms.Features/Quartz/JobOrchestrator.cs index 4f578b5..ed90adf 100644 --- a/LiteCharms.Features/Quartz/JobOrchestrator.cs +++ b/LiteCharms.Features/Quartz/JobOrchestrator.cs @@ -1,6 +1,5 @@ using LiteCharms.Features.Abstractions; using LiteCharms.Features.Quartz.Abstractions; -using static LiteCharms.Features.Extensions.Timezones; namespace LiteCharms.Features.Quartz; @@ -47,12 +46,12 @@ public class JobOrchestrator(ISchedulerFactory schedulerFactory) : IJobOrchestra .StoreDurably() .Build(); - var now = SouthAfricanTimeZone.UtcNow(); + var now = DateTime.UtcNow; var trigger = global::Quartz.TriggerBuilder.Create() .WithIdentity(triggerKey) - .WithDescription($"Scheduled via Main Job at {now:g}") - .WithCronSchedule(cronExpression, cron => cron.InTimeZone(SouthAfricanTimeZone) + .WithDescription($"Scheduled via Main Job at {now:g} UTC") + .WithCronSchedule(cronExpression, cron => cron .WithMisfireHandlingInstructionFireAndProceed()) .StartAt(now) .Build(); diff --git a/LiteCharms.Features/Quartz/MediatorJob.cs b/LiteCharms.Features/Quartz/MediatorJob.cs index b3ea928..f67dda1 100644 --- a/LiteCharms.Features/Quartz/MediatorJob.cs +++ b/LiteCharms.Features/Quartz/MediatorJob.cs @@ -1,4 +1,5 @@ using LiteCharms.Features.Abstractions; +using LiteCharms.Features.Mediator; namespace LiteCharms.Features.Quartz; @@ -13,9 +14,12 @@ public class MediatorJob(IMediator mediator) : IJob where TNotifi var notification = JsonSerializer.Deserialize(data); - if(notification is null) return; + if (notification is null) return; + + using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}"); + + activity?.SetTag("event.correlation_id", notification.CorrelationId); - if(notification is TNotification) - await mediator.Publish(notification, context.CancellationToken); + await mediator.Publish(notification, context.CancellationToken); } } diff --git a/LiteCharms.Features/Shop/CartPackages/PackageService.cs b/LiteCharms.Features/Shop/CartPackages/PackageService.cs index 1df6c00..3479998 100644 --- a/LiteCharms.Features/Shop/CartPackages/PackageService.cs +++ b/LiteCharms.Features/Shop/CartPackages/PackageService.cs @@ -51,7 +51,6 @@ public class PackageService(IDbContextFactory contextFactory) var newPackage = context.Packages.Add(new Entities.Package { - UpdatedAt = null, Name = name, Summary = summary, Description = description, @@ -206,7 +205,7 @@ public class PackageService(IDbContextFactory contextFactory) package.Summary = summary; package.Description = description; package.ImageUrl = ImageUrl; - package.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + package.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() diff --git a/LiteCharms.Features/Shop/Leads/LeadService.cs b/LiteCharms.Features/Shop/Leads/LeadService.cs index f8b4637..f099235 100644 --- a/LiteCharms.Features/Shop/Leads/LeadService.cs +++ b/LiteCharms.Features/Shop/Leads/LeadService.cs @@ -103,6 +103,7 @@ public class LeadService(IDbContextFactory contextFactory) return Result.Fail(new Error($"Lead with ID {leadId} not found.")); lead.Status = status; + lead.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() diff --git a/LiteCharms.Features/Shop/Notifications/Events/Handlers/ProcessEmailNotificationsEventHandler.cs b/LiteCharms.Features/Shop/Notifications/Events/Handlers/ProcessEmailNotificationsEventHandler.cs index 6a11fda..18009ce 100644 --- a/LiteCharms.Features/Shop/Notifications/Events/Handlers/ProcessEmailNotificationsEventHandler.cs +++ b/LiteCharms.Features/Shop/Notifications/Events/Handlers/ProcessEmailNotificationsEventHandler.cs @@ -1,7 +1,6 @@ using LiteCharms.Features.Email; -using LiteCharms.Features.Shop.Notifications.Entities; +using LiteCharms.Features.Shop.Notifications.Models; using LiteCharms.Features.Shop.Postgres; -using static LiteCharms.Features.Extensions.Timezones; namespace LiteCharms.Features.Shop.Notifications.Events.Handlers; @@ -17,8 +16,8 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory o.Priority) - .ThenBy(o => o.CreatedAt) + .OrderByDescending(o => o.CreatedAt) + .ThenBy(o => o.Priority) .Where(n => n.CorrelationIdType == CorrelationIdTypes.Email) .Where(n => n.Direction == NotificationDirection.Outgoing) .Take(message.MaxRecords) @@ -44,7 +43,7 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory contextFactory) return Result.Fail(new Error($"Order {request.OrderId} not found")); order.Status = request.Status; - order.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + order.UpdatedAt = DateTime.UtcNow; if(!string.IsNullOrWhiteSpace(request.InvoiceUrl)) order.InvoiceUrl = request.InvoiceUrl; diff --git a/LiteCharms.Features/Shop/Products/ProductService.cs b/LiteCharms.Features/Shop/Products/ProductService.cs index 4b9b294..9016da5 100644 --- a/LiteCharms.Features/Shop/Products/ProductService.cs +++ b/LiteCharms.Features/Shop/Products/ProductService.cs @@ -1,7 +1,6 @@ using LiteCharms.Features.Extensions; using LiteCharms.Features.Shop.Postgres; using LiteCharms.Features.Shop.Products.Models; -using static LiteCharms.Features.Extensions.Timezones; namespace LiteCharms.Features.Shop.Products; @@ -19,7 +18,7 @@ public class ProductService(IDbContextFactory contextFactory) return Result.Fail($"Could not find product price with ID {productPriceId}"); price.Active = active; - price.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + price.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() @@ -200,7 +199,7 @@ public class ProductService(IDbContextFactory contextFactory) return Result.Fail($"Could not find product price with ID {productPriceId}"); existingPrice.Active = false; - existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + existingPrice.UpdatedAt = DateTime.UtcNow; if (!(await context.SaveChangesAsync(cancellationToken) > 0)) return Result.Fail($"Failed to deactivate existing price of ID {productPriceId}, try again later"); @@ -212,7 +211,7 @@ public class ProductService(IDbContextFactory contextFactory) var deactivatedPrice = await context.ProductPrices.FirstOrDefaultAsync(p => p.Id == productPriceId, cancellationToken); existingPrice.Active = true; - existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + existingPrice.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Fail("Reverted to old price, creation of new price failed") diff --git a/LiteCharms.Features/Shop/Quotes/QuoteService.cs b/LiteCharms.Features/Shop/Quotes/QuoteService.cs index 7e726c1..c3de336 100644 --- a/LiteCharms.Features/Shop/Quotes/QuoteService.cs +++ b/LiteCharms.Features/Shop/Quotes/QuoteService.cs @@ -2,7 +2,6 @@ using LiteCharms.Features.Models; using LiteCharms.Features.Shop.Postgres; using LiteCharms.Features.Shop.Quotes.Models; -using static LiteCharms.Features.Extensions.Timezones; namespace LiteCharms.Features.Shop.Quotes; @@ -26,6 +25,7 @@ public class QuoteService(IDbContextFactory contextFactory) return Result.Fail(new Error($"Quote with id {quoteId} is already assigned to order with id {orderId}")); quote.OrderId = orderId; + quote.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() @@ -52,6 +52,7 @@ public class QuoteService(IDbContextFactory contextFactory) return Result.Fail(new Error($"Shopping Cart with id {shoppingCartId} not found")); quote.ShoppingCartId = shoppingCartId; + quote.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() @@ -140,7 +141,7 @@ public class QuoteService(IDbContextFactory contextFactory) return Result.Fail(new Error("Quote not found.")); quote.Status = status; - quote.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + quote.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok() diff --git a/LiteCharms.Features/Shop/ShoppingCarts/ShoppingCartService.cs b/LiteCharms.Features/Shop/ShoppingCarts/ShoppingCartService.cs index b4fdd2f..d7eaf16 100644 --- a/LiteCharms.Features/Shop/ShoppingCarts/ShoppingCartService.cs +++ b/LiteCharms.Features/Shop/ShoppingCarts/ShoppingCartService.cs @@ -1,7 +1,6 @@ using LiteCharms.Features.Extensions; using LiteCharms.Features.Shop.Postgres; using LiteCharms.Features.Shop.ShoppingCarts.Models; -using static LiteCharms.Features.Extensions.Timezones; namespace LiteCharms.Features.Shop.ShoppingCarts; @@ -284,7 +283,7 @@ public class ShoppingCartService(IDbContextFactory contextFactory return Result.Fail($"Shopping cart item could not be found with id {shoppingCartItemId}"); item.Quantity = quantity; - item.UpdatedAt = SouthAfricanTimeZone.UtcNow(); + item.UpdatedAt = DateTime.UtcNow; return await context.SaveChangesAsync(cancellationToken) > 0 ? Result.Ok()