-
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.
- Loading branch information
1 parent
4d0ce02
commit 2fa71e9
Showing
38 changed files
with
425 additions
and
68 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
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.18.0.0 /opt/musiccatalogue.api-1.18.0.0 | ||
WORKDIR /opt/musiccatalogue.api-1.18.0.0/bin | ||
COPY musiccatalogue.api-1.19.0.0 /opt/musiccatalogue.api-1.19.0.0 | ||
WORKDIR /opt/musiccatalogue.api-1.19.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.18.0.0 /opt/musiccatalogue.ui-1.18.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.18.0.0 | ||
COPY musiccatalogue.ui-1.19.0.0 /opt/musiccatalogue.ui-1.19.0.0 | ||
WORKDIR /opt/musiccatalogue.ui-1.19.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
8 changes: 8 additions & 0 deletions
8
src/MusicCatalogue.Api/Entities/ArtistStatisticsExportWorkItem.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 @@ | ||
namespace MusicCatalogue.Api.Entities | ||
{ | ||
public class ArtistStatisticsExportWorkItem : BackgroundWorkItem | ||
{ | ||
public string FileName { get; set; } = ""; | ||
public bool WishList { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/MusicCatalogue.Api/Entities/GenreStatisticsExportWorkItem.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 @@ | ||
namespace MusicCatalogue.Api.Entities | ||
{ | ||
public class GenreStatisticsExportWorkItem : BackgroundWorkItem | ||
{ | ||
public string FileName { get; set; } = ""; | ||
public bool WishList { get; set; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/MusicCatalogue.Api/Entities/MonthlySpendExportWorkItem.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,7 @@ | ||
namespace MusicCatalogue.Api.Entities | ||
{ | ||
public class MonthlySpendExportWorkItem : BackgroundWorkItem | ||
{ | ||
public string FileName { 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
47 changes: 47 additions & 0 deletions
47
src/MusicCatalogue.Api/Services/ArtistStatisticsExportService.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,47 @@ | ||
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; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace MusicCatalogue.Api.Services | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class ArtistStatisticsExportService : BackgroundQueueProcessor<ArtistStatisticsExportWorkItem> | ||
{ | ||
private readonly MusicApplicationSettings _settings; | ||
public ArtistStatisticsExportService( | ||
ILogger<BackgroundQueueProcessor<ArtistStatisticsExportWorkItem>> logger, | ||
IBackgroundQueue<ArtistStatisticsExportWorkItem> queue, | ||
IServiceScopeFactory serviceScopeFactory, | ||
IOptions<MusicApplicationSettings> settings) | ||
: base(logger, queue, serviceScopeFactory) | ||
{ | ||
_settings = settings.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Export the artist statistics report | ||
/// </summary> | ||
/// <param name="item"></param> | ||
/// <param name="factory"></param> | ||
/// <returns></returns> | ||
protected override async Task ProcessWorkItem(ArtistStatisticsExportWorkItem item, IMusicCatalogueFactory factory) | ||
{ | ||
// Get the report data | ||
MessageLogger.LogInformation("Retrieving the artist statistics report for export"); | ||
var records = await factory.ArtistStatistics.GenerateReportAsync(item.WishList, 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<ArtistStatistics>(); | ||
exporter.Export(records, filePath, ','); | ||
MessageLogger.LogInformation("Artist statistics report export completed"); | ||
} | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/MusicCatalogue.Api/Services/GenreStatisticsExportService.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 GenreStatisticsExportService : BackgroundQueueProcessor<GenreStatisticsExportWorkItem> | ||
{ | ||
private readonly MusicApplicationSettings _settings; | ||
public GenreStatisticsExportService( | ||
ILogger<BackgroundQueueProcessor<GenreStatisticsExportWorkItem>> logger, | ||
IBackgroundQueue<GenreStatisticsExportWorkItem> queue, | ||
IServiceScopeFactory serviceScopeFactory, | ||
IOptions<MusicApplicationSettings> settings) | ||
: base(logger, queue, serviceScopeFactory) | ||
{ | ||
_settings = settings.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Export the genre statistics report | ||
/// </summary> | ||
/// <param name="item"></param> | ||
/// <param name="factory"></param> | ||
/// <returns></returns> | ||
protected override async Task ProcessWorkItem(GenreStatisticsExportWorkItem item, IMusicCatalogueFactory factory) | ||
{ | ||
// Get the report data | ||
MessageLogger.LogInformation("Retrieving the genre statistics report for export"); | ||
var records = await factory.GenreStatistics.GenerateReportAsync(item.WishList, 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<GenreStatistics>(); | ||
exporter.Export(records, filePath, ','); | ||
MessageLogger.LogInformation("Genre statistics report export completed"); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/MusicCatalogue.Api/Services/MonthlySpendExportService.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 MonthlySpendExportService : BackgroundQueueProcessor<MonthlySpendExportWorkItem> | ||
{ | ||
private readonly MusicApplicationSettings _settings; | ||
public MonthlySpendExportService( | ||
ILogger<BackgroundQueueProcessor<MonthlySpendExportWorkItem>> logger, | ||
IBackgroundQueue<MonthlySpendExportWorkItem> queue, | ||
IServiceScopeFactory serviceScopeFactory, | ||
IOptions<MusicApplicationSettings> settings) | ||
: base(logger, queue, serviceScopeFactory) | ||
{ | ||
_settings = settings.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Export the monthly spend report | ||
/// </summary> | ||
/// <param name="item"></param> | ||
/// <param name="factory"></param> | ||
/// <returns></returns> | ||
protected override async Task ProcessWorkItem(MonthlySpendExportWorkItem item, IMusicCatalogueFactory factory) | ||
{ | ||
// Get the report data | ||
MessageLogger.LogInformation("Retrieving the monthly spending report for export"); | ||
var records = await factory.MonthlySpend.GenerateReportAsync(false, 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<MonthlySpend>(); | ||
exporter.Export(records, filePath, ','); | ||
MessageLogger.LogInformation("Monthly spending report export completed"); | ||
} | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/MusicCatalogue.Entities/DataExchange/ExportEventArgs.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,11 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace MusicCatalogue.Entities.DataExchange | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class ExportEventArgs<T> : EventArgs where T : class | ||
{ | ||
public long RecordCount { get; set; } | ||
public T? RecordSource { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using MusicCatalogue.Entities.DataExchange; | ||
|
||
namespace MusicCatalogue.Entities.Interfaces | ||
{ | ||
public interface ICsvExporter<T> where T : class | ||
{ | ||
event EventHandler<ExportEventArgs<T>> RecordExport; | ||
void Export(IEnumerable<T> entities, string fileName, char separator); | ||
} | ||
} |
Oops, something went wrong.