-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from davewalker5/MC-308-Genre-Albums-Report
Implement the Albums by Genre Report
- Loading branch information
Showing
46 changed files
with
1,115 additions
and
179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:latest | ||
COPY musiccatalogue.api-1.25.0.0 /opt/musiccatalogue.api-1.25.0.0 | ||
WORKDIR /opt/musiccatalogue.api-1.25.0.0/bin | ||
COPY musiccatalogue.api-1.30.0.0 /opt/musiccatalogue.api-1.30.0.0 | ||
WORKDIR /opt/musiccatalogue.api-1.30.0.0/bin | ||
ENTRYPOINT [ "./MusicCatalogue.Api" ] |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM node:20-alpine | ||
COPY musiccatalogue.ui-1.29.0.0 /opt/musiccatalogue.ui-1.29.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.29.0.0 | ||
COPY musiccatalogue.ui-1.30.0.0 /opt/musiccatalogue.ui-1.30.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.30.0.0 | ||
RUN npm install | ||
RUN npm run build | ||
ENTRYPOINT [ "npm", "start" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace MusicCatalogue.Api.Entities | ||
{ | ||
public class GenreAlbumsExportWorkItem : BackgroundWorkItem | ||
{ | ||
public string FileName { get; set; } = ""; | ||
public int GenreId { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicCatalogue.Api", "MusicCatalogue.Api.csproj", "{161E1F59-74B9-4B7F-A41D-124733824FA2}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{161E1F59-74B9-4B7F-A41D-124733824FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{161E1F59-74B9-4B7F-A41D-124733824FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{161E1F59-74B9-4B7F-A41D-124733824FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{161E1F59-74B9-4B7F-A41D-124733824FA2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B6903EC5-48B3-48BA-9C2D-F0F52303EE9E} | ||
EndGlobalSection | ||
EndGlobal |
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
45 changes: 45 additions & 0 deletions
45
src/MusicCatalogue.Api/Services/GenreAlbumsExportService.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,45 @@ | ||
using Microsoft.Extensions.Options; | ||
using MusicCatalogue.Api.Entities; | ||
using MusicCatalogue.Api.Interfaces; | ||
using MusicCatalogue.Entities.Config; | ||
using MusicCatalogue.Entities.Interfaces; | ||
using MusicCatalogue.Entities.Reporting; | ||
using MusicCatalogue.Logic.DataExchange.Generic; | ||
|
||
namespace MusicCatalogue.Api.Services | ||
{ | ||
public class GenreAlbumsExportService : BackgroundQueueProcessor<GenreAlbumsExportWorkItem> | ||
{ | ||
private readonly MusicApplicationSettings _settings; | ||
public GenreAlbumsExportService( | ||
ILogger<BackgroundQueueProcessor<GenreAlbumsExportWorkItem>> logger, | ||
IBackgroundQueue<GenreAlbumsExportWorkItem> queue, | ||
IServiceScopeFactory serviceScopeFactory, | ||
IOptions<MusicApplicationSettings> settings) | ||
: base(logger, queue, serviceScopeFactory) | ||
{ | ||
_settings = settings.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Export the albums by genre report | ||
/// </summary> | ||
/// <param name="item"></param> | ||
/// <param name="factory"></param> | ||
/// <returns></returns> | ||
protected override async Task ProcessWorkItem(GenreAlbumsExportWorkItem item, IMusicCatalogueFactory factory) | ||
{ | ||
// Get the report data | ||
MessageLogger.LogInformation("Retrieving the albums by genre report for export"); | ||
var records = await factory.GenreAlbums.GenerateReportAsync(item.GenreId, 1, int.MaxValue); | ||
|
||
// Construct the full path to the export file | ||
var filePath = Path.Combine(_settings.ReportsExportPath, item.FileName); | ||
|
||
// Export the report | ||
var exporter = new CsvExporter<GenreAlbum>(); | ||
exporter.Export(records, filePath, ','); | ||
MessageLogger.LogInformation("Albums by genre report export completed"); | ||
} | ||
} | ||
} |
Oops, something went wrong.