Skip to content

Commit

Permalink
Merge pull request #159 from WoW-2-0-Projects/feature/#98
Browse files Browse the repository at this point in the history
Create `FeedbackAnalysisResultCreatedEvent` and `FeedbackAnalysisWorkflowResultUpdateEvent`
  • Loading branch information
sulton-max authored Mar 29, 2024
2 parents a476645 + 4b4ed58 commit 95fd377
Show file tree
Hide file tree
Showing 49 changed files with 3,667 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Feedback.Analyzer.Api.Middlewares;
using Feedback.Analyzer.Application.Clients.Services;
using Feedback.Analyzer.Application.Common.AnalysisWorkflows.Services;
using Feedback.Analyzer.Application.Common.Caching;
using Feedback.Analyzer.Application.Common.EventBus.Brokers;
using Feedback.Analyzer.Application.Common.Identity.Services;
using Feedback.Analyzer.Application.Common.PromptCategory.Services;
Expand All @@ -28,6 +27,7 @@
using Feedback.Analyzer.Domain.Extensions;
using Feedback.Analyzer.Infrastructure.Clients.Services;
using Feedback.Analyzer.Infrastructure.Common.AnalysisWorkflows.Services;
using Feedback.Analyzer.Infrastructure.Common.Caching;
using Feedback.Analyzer.Infrastructure.Common.EventBus.Brokers;
using Feedback.Analyzer.Infrastructure.Common.EventBus.Extensions;
using Feedback.Analyzer.Infrastructure.Common.Identity.Services;
Expand Down Expand Up @@ -125,10 +125,10 @@ private static WebApplicationBuilder AddCaching(this WebApplicationBuilder build
builder.Services.Configure<CacheSettings>(builder.Configuration.GetSection(nameof(CacheSettings)));

// Register the Memory Cache service.
builder.Services.AddMemoryCache();
builder.Services.AddLazyCache();

// Register the Memory Cache as a singleton.
builder.Services.AddSingleton<ICacheBroker, MemoryCacheBroker>();
builder.Services.AddSingleton<ICacheBroker, LazyMemoryCacheBroker>();

// Register middlewares
builder.Services.AddSingleton<AccessTokenValidationMiddleware>();
Expand Down Expand Up @@ -175,14 +175,15 @@ private static WebApplicationBuilder AddEventBus(this WebApplicationBuilder buil
/// <returns></returns>
private static WebApplicationBuilder AddPersistence(this WebApplicationBuilder builder)
{
// define db connection string based on runtime environment
// Register settings
builder.Services.Configure<JwtSettings>(builder.Configuration.GetSection(nameof(JwtSettings)));

// Define db connection string based on runtime environment
var dbConnectionString = builder.Environment.IsProduction()
? Environment.GetEnvironmentVariable(DataAccessConstants.DbConnectionString)
: builder.Configuration.GetConnectionString(DataAccessConstants.DbConnectionString);

// register ef interceptors

//register db context
// Register db context
builder.Services.AddDbContext<AppDbContext>(options =>
{
options.UseNpgsql(dbConnectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
<PackageReference Include="MassTransit.Extensions.DependencyInjection" Version="7.3.1" />
<PackageReference Include="MassTransit.Newtonsoft" Version="8.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.Clients.Models;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ public interface IEventBusBroker
/// </summary>
/// <typeparam name="TEvent">Type of the event to be published.</typeparam>
/// <param name="event">The event to be published.</param>
/// <param name="cancellationToken">A cancellation token to cancel the asynchronous operation (optional).</param>
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
ValueTask PublishLocalAsync<TEvent>(TEvent @event) where TEvent : EventBase;
ValueTask PublishLocalAsync<TEvent>(TEvent @event, CancellationToken cancellationToken = default) where TEvent : EventBase;

/// <summary>
/// Publishes an event asynchronously.
/// </summary>
/// <typeparam name="TEvent">Type of the event to be published.</typeparam>
/// <param name="event">The event to be published.</param>
/// <param name="cancellationToken">A cancellation token to cancel the asynchronous operation (optional).</param>
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
ValueTask PublishAsync<TEvent>(TEvent @event) where TEvent : EventBase;
ValueTask PublishAsync<TEvent>(TEvent @event, CancellationToken cancellationToken = default) where TEvent : EventBase;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.Common.PromptCategory.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.Common.Prompts.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.CustomerFeedbacks.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Feedback.Analyzer.Domain.Common.Events;
using Feedback.Analyzer.Domain.Entities;

namespace Feedback.Analyzer.Application.FeedbackAnalysisResults.Events;

/// <summary>
/// Represents feedback analysis result creation event
/// </summary>
public record FeedbackAnalysisResultCreatedEvent : EventBase
{
/// <summary>
/// Created feedback analysis result
/// </summary>
public FeedbackAnalysisResult FeedbackAnalysisResult { get; init; } = default!;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.FeedbackAnalysisResults.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Feedback.Analyzer.Domain.Common.Events;

namespace Feedback.Analyzer.Application.FeedbackAnalysisWorkflowResults.Events;

/// <summary>
/// Represents feedback analysis workflow result update event
/// </summary>
/// <param name="WorkflowResultId">Workflow result id to update</param>
public record FeedbackAnalysisWorkflowResultUpdateEvent(Guid WorkflowResultId) : EventBase;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Feedback.Analyzer.Application.Organizations.Models;
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.FeedbackAnalysisWorkflowResults.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Feedback.Analyzer.Domain.Entities;

namespace Feedback.Analyzer.Application.FeedbackAnalysisWorkflowResults.Models;

/// <summary>
/// Represents the progress of a feedback analysis workflow result.
/// </summary>
public struct FeedbackAnalysisWorkflowResultProgress(FeedbackAnalysisWorkflowResult workflowResult)
{
/// <summary>
/// Gets or the identifier of the workflow result.
/// </summary>
public Guid WorkflowResultId { get; init; } = workflowResult.Id;

/// <summary>
/// Gets the total number of feedbacks.
/// </summary>
public uint FeedbacksCount { get; init; } = workflowResult.FeedbacksCount;

/// <summary>
/// Gets or sets the number of feedbacks that have been analysed.
/// </summary>
public uint AnalyzedFeedbacksCount { get; set; } = default;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;
using Feedback.Analyzer.Domain.Enums;

namespace Feedback.Analyzer.Application.FeedbackAnalysisWorkflows.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.Organizations.Models;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Feedback.Analyzer.Domain.Common.Query;
using Feedback.Analyzer.Domain.Common.Queries;

namespace Feedback.Analyzer.Application.Products.Models;

Expand Down
Loading

0 comments on commit 95fd377

Please sign in to comment.