-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added strict match checkboxes for workshop filter (#772)
* Added strict match checkboxes for workshop filter * Fixed code smels * Implemented pattern Strategy for workshop * Refactored code using dependency injection * Small refactor * small refactor
- Loading branch information
Showing
10 changed files
with
105 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
OutOfSchool/OutOfSchool.WebApi/Services/Strategies/Interfaces/IWorkshopStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using OutOfSchool.WebApi.Models; | ||
|
||
namespace OutOfSchool.WebApi.Services.Strategies.Interfaces; | ||
|
||
public interface IWorkshopStrategy | ||
{ | ||
Task<SearchResult<WorkshopCard>> SearchAsync(WorkshopFilter filter); | ||
} |
28 changes: 28 additions & 0 deletions
28
OutOfSchool/OutOfSchool.WebApi/Services/Strategies/WorkshopStrategies/WorkshopESStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using OutOfSchool.WebApi.Models; | ||
using OutOfSchool.WebApi.Services.Strategies.Interfaces; | ||
|
||
namespace OutOfSchool.WebApi.Services.Strategies.WorkshopStrategies; | ||
|
||
public class WorkshopESStrategy : IWorkshopStrategy | ||
{ | ||
private readonly IElasticsearchService<WorkshopES, WorkshopFilterES> elasticsearchService; | ||
private readonly ILogger<WorkshopESStrategy> logger; | ||
|
||
public WorkshopESStrategy(IElasticsearchService<WorkshopES, WorkshopFilterES> elasticsearchService, ILogger<WorkshopESStrategy> logger) | ||
{ | ||
this.elasticsearchService = elasticsearchService ?? throw new ArgumentNullException(); | ||
this.logger = logger; | ||
} | ||
|
||
public async Task<SearchResult<WorkshopCard>> SearchAsync(WorkshopFilter filter) | ||
{ | ||
var result = await elasticsearchService.Search(filter.ToESModel()).ConfigureAwait(false); | ||
|
||
if (result.TotalAmount <= 0) | ||
{ | ||
logger?.LogInformation($"Result was {result.TotalAmount}"); | ||
} | ||
|
||
return result.ToSearchResult(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...hool/OutOfSchool.WebApi/Services/Strategies/WorkshopStrategies/WorkshopServiceStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using OutOfSchool.WebApi.Models; | ||
using OutOfSchool.WebApi.Services.Strategies.Interfaces; | ||
|
||
namespace OutOfSchool.WebApi.Services.Strategies.WorkshopStrategies; | ||
|
||
public class WorkshopServiceStrategy : IWorkshopStrategy | ||
{ | ||
private readonly IWorkshopService workshopService; | ||
private readonly ILogger<WorkshopServiceStrategy> logger; | ||
|
||
public WorkshopServiceStrategy(IWorkshopService workshopService, ILogger<WorkshopServiceStrategy> logger) | ||
{ | ||
this.workshopService = workshopService ?? throw new ArgumentNullException(); | ||
this.logger = logger; | ||
} | ||
|
||
public async Task<SearchResult<WorkshopCard>> SearchAsync(WorkshopFilter filter) | ||
{ | ||
var databaseResult = await workshopService.GetByFilter(filter).ConfigureAwait(false); | ||
|
||
if (databaseResult.TotalAmount <= 0) | ||
{ | ||
logger?.LogInformation($"Result was {databaseResult.TotalAmount}"); | ||
} | ||
|
||
return new SearchResult<WorkshopCard>() { TotalAmount = databaseResult.TotalAmount, Entities = databaseResult.Entities }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
OutOfSchool/OutOfSchool.WebApi/Services/WorkshopServicesCombinerV2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters