Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/express-4.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhavat authored Sep 17, 2024
2 parents b471d97 + d3a2e69 commit ce82b01
Show file tree
Hide file tree
Showing 43 changed files with 970 additions and 74 deletions.
2 changes: 1 addition & 1 deletion PRODUCTION_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
| [date-fns-tz](https://github.com/marnusw/date-fns-tz) | 2.0.0 | MIT |
| [date-fns](https://github.com/date-fns/date-fns) | 2.29.2 | MIT |
| [dayjs](https://github.com/iamkun/dayjs) | 1.11.10 | MIT |
| [express](https://github.com/expressjs/express) | 4.19.2 | MIT |
| [express](https://github.com/expressjs/express) | 4.21.0 | MIT |
| [graphql-sse](https://github.com/enisdenjo/graphql-sse) | 2.5.3 | MIT |
| [graphql](https://github.com/graphql/graphql-js) | 16.8.1 | MIT |
| [highlight.js](https://github.com/highlightjs/highlight.js) | 11.10.0 | BSD-3-Clause |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ type SettlementReport {
statusType: SettlementReportStatusType!
executionTime: DateRange!
fromApi: Boolean!
splitReportPerGridArea: Boolean!
combineResultInASingleFile: Boolean!
includeMonthlyAmount: Boolean!
gridAreas: [String!]!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ public interface ISettlementReportsClient
/// Downloads the settlement report with the specified id.
/// </summary>
/// <returns>The stream to the report.</returns>
public Task<Stream> DownloadAsync(SettlementReportRequestId requestId, CancellationToken cancellationToken);
public Task<Stream> DownloadAsync(SettlementReportRequestId requestId, bool fromApi, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ public async Task<IEnumerable<RequestedSettlementReportDto>> GetAsync(Cancellati
return actualResponseContent.Concat(actualResponseApiContent).OrderByDescending(x => x.CreatedDateTime);
}

public async Task<Stream> DownloadAsync(SettlementReportRequestId requestId, CancellationToken cancellationToken)
public async Task<Stream> DownloadAsync(SettlementReportRequestId requestId, bool fromApi, CancellationToken cancellationToken)
{
using var requestApi = new HttpRequestMessage(HttpMethod.Get, "settlement-reports/download");
using var request = new HttpRequestMessage(HttpMethod.Post, "api/SettlementReportDownload");
request.Content = new StringContent(
JsonConvert.SerializeObject(requestId),
Encoding.UTF8,
"application/json");

var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
var response = await (fromApi
? _apiHttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
: _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken));

response.EnsureSuccessStatusCode();

return await response.Content.ReadAsStreamAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public WholesaleSettlementReportController(

[HttpGet("DownloadReport")]
[Produces("application/zip")]
public async Task<ActionResult<Stream>> DownloadReportAsync([FromQuery] string settlementReportId)
public async Task<ActionResult<Stream>> DownloadReportAsync([FromQuery] string settlementReportId, [FromQuery] bool fromApi)
{
var reportStream = await _settlementReportsClient.DownloadAsync(new SettlementReportRequestId(settlementReportId), default);
var reportStream = await _settlementReportsClient.DownloadAsync(new SettlementReportRequestId(settlementReportId), fromApi, default);
var fileName = "SettlementReport.zip";
return File(reportStream, MediaTypeNames.Application.Zip, fileName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ public async Task<IEnumerable<SettlementReport>> GetSettlementReportsAsync(
};

settlementReports.Add(new SettlementReport(
report.RequestId.Id,
actor,
report.CalculationType,
new Interval(report.PeriodStart.ToInstant(), report.PeriodEnd.ToInstant()),
report.GridAreaCount,
report.ContainsBasisData,
string.Empty,
report.Progress,
settlementReportStatusType,
new Interval(Instant.FromDateTimeOffset(report.CreatedDateTime), report.EndedDateTime != null ? Instant.FromDateTimeOffset(report.EndedDateTime.Value) : null),
report.JobId is not null,
report.SplitReportPerGridArea,
report.IncludeMonthlyAmount,
report.GridAreas.Select(ga => ga.Key).ToArray()));
Id: report.RequestId.Id,
Actor: actor,
CalculationType: report.CalculationType,
Period: new Interval(report.PeriodStart.ToInstant(), report.PeriodEnd.ToInstant()),
NumberOfGridAreasInReport: report.GridAreaCount,
IncludesBasisData: report.ContainsBasisData,
StatusMessage: string.Empty,
Progress: report.Progress,
StatusType: settlementReportStatusType,
ExecutionTime: new Interval(Instant.FromDateTimeOffset(report.CreatedDateTime), report.EndedDateTime != null ? Instant.FromDateTimeOffset(report.EndedDateTime.Value) : null),
FromApi: report.JobId is not null,
CombineResultInASingleFile: !report.SplitReportPerGridArea,
IncludeMonthlyAmount: report.IncludeMonthlyAmount,
GridAreas: report.GridAreas.Select(ga => ga.Key).ToArray()));
}

return settlementReports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public async Task<IEnumerable<GridAreaDto>> GetGridAreasAsync(
httpContextAccessor.HttpContext!,
"DownloadReport",
"WholesaleSettlementReport",
new { settlementReportId = result.Id });
new { settlementReportId = result.Id, result.FromApi });
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public sealed record SettlementReport(
SettlementReportStatusType StatusType,
Interval ExecutionTime,
bool FromApi,
bool SplitReportPerGridArea,
bool CombineResultInASingleFile,
bool IncludeMonthlyAmount,
string[] GridAreas);
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"p-001": "produktion"
},
"duration": {
"seconds": "{{ seconds }}s",
"minutes": "{{ minutes }}m",
"hours": "{{ hours }}t {{ duration.minutes }}",
"days": "{{ days }}d {{ duration.hours }}"
Expand Down Expand Up @@ -1127,7 +1128,14 @@
"numberOfGridAreasInReport": "Netområder",
"basisData": "Datagrundlag",
"status": "Status",
"actorName": "Aktørnavn"
"actorName": "Aktør"
},
"noData": "Ingen data",
"gridAreasAndCount": "{{ gridAreas }}, +{{ remainingGridAreasCount }} flere",
"drawer": {
"monthlySum": "Månedssummer",
"combined": "Kombineret",
"gridAreas": "Netområder"
},
"reportStatus": {
"IN_PROGRESS": "I gang ({{ progress }}%)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"p-001": "production"
},
"duration": {
"seconds": "{{ seconds }}s",
"minutes": "{{ minutes }}m",
"hours": "{{ hours }}h {{ duration.minutes }}",
"days": "{{ days }}d {{ duration.hours }}"
Expand Down Expand Up @@ -1130,6 +1131,13 @@
"status": "Status",
"actorName": "Market participant"
},
"noData": "No data",
"gridAreasAndCount": "{{ gridAreas }}, +{{ remainingGridAreasCount }} more",
"drawer": {
"monthlySum": "Monthly sum",
"combined": "Kombineret",
"gridAreas": "Grid areas"
},
"reportStatus": {
"IN_PROGRESS": "In progress ({{ progress }}%)",
"ERROR": "Error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h2 class="actor-heading">
</ng-container>
}

<watt-tab [label]="t('tabs.history.tabLabel')" *dhPermissionRequired="['fas']">
<watt-tab [label]="t('tabs.history.tabLabel')" *dhPermissionRequired="['actors:manage']">
<dh-actor-audit-log-tab
[actorId]="actor()?.id!"
[actorNumberNameLookup]="actorNumberNameLookup()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class DhDelegationStopModalComponent extends WattTypedModal<DhDelegation[
delegationId: delegation.id,
stopPeriod: {
periodId: delegation.periodId,
stopDate: this.calculateStopDate(selectedOption, stopDate),
stopsAt: this.calculateStopDate(selectedOption, stopDate),
},
};
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h2 class="organization-heading">{{ organization?.name }}</h2>
</watt-card>
}
</watt-tab>
<watt-tab [label]="t('tabs.history.tabLabel')" *dhPermissionRequired="['fas']">
<watt-tab [label]="t('tabs.history.tabLabel')" *dhPermissionRequired="['actors:manage']">
<dh-organization-history [organizationId]="organization?.id!" />
</watt-tab>
</watt-tabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const periodEnd = new Date('2021-12-02T23:00:00Z');
const executionTimeStart = new Date('2024-09-11T06:12:00Z');

const executionTimeEnd_Days = new Date('2024-09-12T17:15:00Z');
const executionTimeStart_Hours = new Date('2024-09-11T14:44:00Z');
const executionTimeStart_Minutes = new Date('2024-09-11T06:48:00Z');
const executionTimeEnd_Hours = new Date('2024-09-11T14:44:00Z');
const executionTimeEnd_Minutes = new Date('2024-09-11T06:48:00Z');
const executionTimeEnd_Seconds = new Date('2024-09-11T06:12:42Z');

export const wholesaleSettlementReportsQueryMock = (
apiBase: string
Expand All @@ -54,6 +55,9 @@ export const wholesaleSettlementReportsQueryMock = (
},
settlementReportDownloadUrl: `${apiBase}/v1/WholesaleSettlementReport/DownloadReport`,
fromApi: true,
includeMonthlyAmount: true,
combineResultInASingleFile: true,
gridAreas: ['003', '004', '005', '006', '007'],
},
{
__typename: 'SettlementReport',
Expand All @@ -71,17 +75,20 @@ export const wholesaleSettlementReportsQueryMock = (
},
executionTime: {
start: executionTimeStart,
end: executionTimeStart_Hours,
end: executionTimeEnd_Hours,
},
settlementReportDownloadUrl: `${apiBase}/v1/WholesaleSettlementReport/DownloadReport`,
fromApi: true,
includeMonthlyAmount: false,
combineResultInASingleFile: true,
gridAreas: ['100', '101', '102'],
},
{
__typename: 'SettlementReport',
id: '85d1798474654be1b8c2f5bc543ed333',
calculationType: CalculationType.WholesaleFixing,
period: { start: periodStart, end: periodEnd },
numberOfGridAreasInReport: 3,
numberOfGridAreasInReport: 0,
includesBasisData: true,
statusType: SettlementReportStatusType.Error,
progress: 75,
Expand All @@ -92,14 +99,60 @@ export const wholesaleSettlementReportsQueryMock = (
},
executionTime: {
start: executionTimeStart,
end: executionTimeStart_Minutes,
end: executionTimeEnd_Minutes,
},
settlementReportDownloadUrl: `${apiBase}/v1/WholesaleSettlementReport/DownloadReport`,
fromApi: true,
includeMonthlyAmount: true,
combineResultInASingleFile: false,
gridAreas: [],
},
{
__typename: 'SettlementReport',
id: '85d1798474654be1b8c2f5bc543ed444',
calculationType: CalculationType.ThirdCorrectionSettlement,
period: { start: periodStart, end: periodEnd },
numberOfGridAreasInReport: 15,
includesBasisData: false,
statusType: SettlementReportStatusType.Error,
progress: 50,
actor: {
__typename: 'Actor',
id: '3',
name: 'Blå Strøm',
},
executionTime: {
start: executionTimeStart,
end: executionTimeEnd_Seconds,
},
settlementReportDownloadUrl: `${apiBase}/v1/WholesaleSettlementReport/DownloadReport`,
fromApi: true,
includeMonthlyAmount: false,
combineResultInASingleFile: false,
gridAreas: [
'700',
'701',
'702',
'703',
'704',
'705',
'706',
'707',
'708',
'709',
'710',
'711',
'712',
'713',
'714',
'715',
'716',
'718',
],
},
{
__typename: 'SettlementReport',
id: '85d1798474654be1b8c2f5bc543ed555',
calculationType: CalculationType.FirstCorrectionSettlement,
period: { start: periodStart, end: null },
numberOfGridAreasInReport: 42,
Expand All @@ -117,6 +170,9 @@ export const wholesaleSettlementReportsQueryMock = (
},
settlementReportDownloadUrl: `${apiBase}/v1/WholesaleSettlementReport/DownloadReport`,
fromApi: true,
includeMonthlyAmount: true,
combineResultInASingleFile: true,
gridAreas: [],
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,24 @@ export class WholesaleSettlementReportHttp {

/**
* @param settlementReportId
* @param fromApi
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<Stream>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Stream>>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Stream>>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, fromApi?: boolean, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<Stream>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, fromApi?: boolean, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Stream>>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, fromApi?: boolean, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Stream>>;
public v1WholesaleSettlementReportDownloadReportGet(settlementReportId?: string, fromApi?: boolean, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/zip', context?: HttpContext, transferCache?: boolean}): Observable<any> {

let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (settlementReportId !== undefined && settlementReportId !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>settlementReportId, 'settlementReportId');
}
if (fromApi !== undefined && fromApi !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>fromApi, 'fromApi');
}

let localVarHeaders = this.defaultHeaders;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ query getSettlementReports {
settlementReportDownloadUrl
executionTime
fromApi
combineResultInASingleFile
includeMonthlyAmount
gridAreas
}
}
Loading

0 comments on commit ce82b01

Please sign in to comment.