Skip to content

Commit 19586c1

Browse files
authored
Merge pull request #1811 from bcgov/revert-1807-master
Revert "Report performance improvements"
2 parents c823898 + ebce578 commit 19586c1

File tree

5 files changed

+19
-31
lines changed

5 files changed

+19
-31
lines changed

ess/src/API/EMBC.ESS/Managers/Reports/ReportsManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public async Task Handle(EvacueeReportRequested evt)
7676
evacueeQuery.EvacuatedFrom = communities.SingleOrDefault(c => c.Code == evacueeQuery.EvacuatedFrom)?.Name;
7777
evacueeQuery.EvacuatedTo = communities.SingleOrDefault(c => c.Code == evacueeQuery.EvacuatedTo)?.Name;
7878

79-
var csv = evacuees.ToCSV(evacueeQuery, "\"");
79+
var csv = evacuees.ToCSV(evacueeQuery);
8080

8181
var content = Encoding.UTF8.GetBytes(csv);
8282
var contentType = "text/csv";
@@ -87,7 +87,7 @@ public async Task Handle(EvacueeReportRequested evt)
8787
ContentType = contentType
8888
};
8989
var cacheKey = ReportRequestKey(evt.ReportRequestId);
90-
await cache.Set(cacheKey, report, TimeSpan.FromMinutes(10));
90+
await cache.Set(cacheKey, report, TimeSpan.FromHours(1));
9191
}
9292

9393
public async Task<ReportQueryResult> Handle(EvacueeReportQuery query)
@@ -147,7 +147,7 @@ public async Task Handle(SupportReportRequested evt)
147147
ContentType = contentType
148148
};
149149
var cacheKey = ReportRequestKey(evt.ReportRequestId);
150-
await cache.Set(cacheKey, report, TimeSpan.FromMinutes(10));
150+
await cache.Set(cacheKey, report, TimeSpan.FromHours(1));
151151
}
152152

153153
public async Task<ReportQueryResult> Handle(SupportReportQuery query)

ess/src/API/EMBC.ESS/Resources/Reports/ReportRepository.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<EvacueeQueryResult> QueryEvacuee(ReportQuery query)
3838
public async Task<SupportQueryResult> QuerySupport(ReportQuery query)
3939
{
4040
var ct = new CancellationTokenSource().Token;
41-
var files = (await QueryEvacuationFiles(readCtx, query, ct)).Concat(await QueryTasks(readCtx, query, ct)).ToList();
41+
var files = (await QueryEvacuationFiles(readCtx, query, ct)).Concat(await QueryTasks(readCtx, query, ct));
4242

4343
var results = await ParallelLoadSupportsAsync(readCtx, files, ct);
4444

@@ -65,9 +65,9 @@ private static async Task<IEnumerable<era_evacuationfile>> QueryEvacuationFiles(
6565
if (query.StartDate.HasValue) filesQuery = filesQuery.Where(f => f.createdon >= query.StartDate.Value);
6666
if (query.EndDate.HasValue) filesQuery = filesQuery.Where(f => f.createdon <= query.EndDate.Value);
6767

68-
IEnumerable<era_evacuationfile> files = (await ((DataServiceQuery<era_evacuationfile>)filesQuery).GetAllPagesAsync(ct)).ToList();
69-
if (!string.IsNullOrEmpty(query.TaskNumber)) files = files.Where(f => f.era_TaskId != null && f.era_TaskId.era_name.Equals(query.TaskNumber, StringComparison.OrdinalIgnoreCase));
70-
if (!string.IsNullOrEmpty(query.EvacuatedTo)) files = files.Where(f => f.era_TaskId != null && f.era_TaskId._era_jurisdictionid_value == Guid.Parse(query.EvacuatedTo));
68+
var files = (await ((DataServiceQuery<era_evacuationfile>)filesQuery).GetAllPagesAsync(ct)).ToArray();
69+
if (!string.IsNullOrEmpty(query.TaskNumber)) files = files.Where(f => f.era_TaskId != null && f.era_TaskId.era_name.Equals(query.TaskNumber, StringComparison.OrdinalIgnoreCase)).ToArray();
70+
if (!string.IsNullOrEmpty(query.EvacuatedTo)) files = files.Where(f => f.era_TaskId != null && f.era_TaskId._era_jurisdictionid_value == Guid.Parse(query.EvacuatedTo)).ToArray();
7171

7272
return files;
7373
}
@@ -85,7 +85,7 @@ private static async Task<IEnumerable<era_evacuationfile>> QueryTasks(EssContext
8585
if (!string.IsNullOrEmpty(query.TaskNumber)) taskQuery = taskQuery.Where(f => f.era_name == query.TaskNumber);
8686
if (!string.IsNullOrEmpty(query.EvacuatedTo)) taskQuery = taskQuery.Where(f => f._era_jurisdictionid_value == Guid.Parse(query.EvacuatedTo));
8787

88-
var tasks = (await ((DataServiceQuery<era_task>)taskQuery).GetAllPagesAsync(ct)).ToList();
88+
var tasks = (await ((DataServiceQuery<era_task>)taskQuery).GetAllPagesAsync(ct)).ToArray();
8989

9090
await Parallel.ForEachAsync(tasks, ct, async (t, ct) =>
9191
{
@@ -123,7 +123,7 @@ private static async Task ParallelLoadEvacueeAsync(EssContext ctx, era_evacuatio
123123
.Expand(m => m.era_Registrant)
124124
.Where(m => m._era_evacuationfileid_value == file.era_evacuationfileid))
125125
.GetAllPagesAsync(ct))
126-
.ToList();
126+
.ToArray();
127127

128128
householdMembers.AsParallel().ForAll(m => m.era_EvacuationFileid = file);
129129
file.era_era_evacuationfile_era_householdmember_EvacuationFileid = new Collection<era_householdmember>(householdMembers);
@@ -151,15 +151,15 @@ private static async Task ParallelLoadSupportAsync(EssContext ctx, era_evacuatio
151151
.Expand(s => s.era_GroupLodgingCityID)
152152
.Where(s => s._era_evacuationfileid_value == file.era_evacuationfileid))
153153
.GetAllPagesAsync(ct))
154-
.ToList();
154+
.ToArray();
155155

156156
supports.AsParallel().ForAll(s => ctx.AttachTo(nameof(EssContext.era_evacueesupports), s));
157157

158158
loadTasks.AddRange(supports.Select(s => ctx.LoadPropertyAsync(s, nameof(era_evacueesupport.era_era_householdmember_era_evacueesupport), ct)));
159159

160160
await Task.WhenAll(loadTasks);
161161

162-
file.era_era_evacuationfile_era_evacueesupport_ESSFileId = new Collection<era_evacueesupport>(supports);
162+
file.era_era_evacuationfile_era_evacueesupport_ESSFileId = new Collection<era_evacueesupport>(supports.ToArray());
163163
if (file.era_TaskId != null) file.era_TaskId.era_JurisdictionID = ctx.LookupJurisdictionByCode(file.era_TaskId._era_jurisdictionid_value?.ToString());
164164
supports.AsParallel().ForAll(s =>
165165
{

responders/src/UI/embc-responder/src/app/feature-components/reporting/reporting.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ReportingComponent implements OnInit, OnDestroy {
3838
private alertService: AlertService,
3939
private locationService: LocationsService,
4040
private customValidation: CustomValidationService
41-
) { }
41+
) {}
4242

4343
ngOnInit(): void {
4444
this.createReportingForm();
@@ -80,8 +80,8 @@ export class ReportingComponent implements OnInit, OnDestroy {
8080
switchMap((reportId) =>
8181
this.reportService
8282
.reportsGetEvacueeReport({ reportRequestId: reportId })
83-
// try to get the report for 10 minutes
84-
.pipe(retry({ delay: 10000, count: 60 }))
83+
// try to get the report for 5 minutes
84+
.pipe(retry({ delay: 6000, count: 50 }))
8585
)
8686
)
8787
.subscribe({

shared/src/EMBC.Utilities.Messaging/Grpc/Configuration.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ namespace EMBC.Utilities.Messaging.Grpc
2727
{
2828
public static class Configuration
2929
{
30-
private static readonly int maximumMessageSize = 15 * 1024 * 1024; // 15MB
31-
3230
public static void Configure(ConfigurationServices configurationServices, MessagingOptions options)
3331
{
3432
configurationServices.Services.AddGrpc(opts =>
3533
{
3634
opts.EnableDetailedErrors = configurationServices.Environment.IsDevelopment();
37-
opts.MaxReceiveMessageSize = maximumMessageSize;
38-
opts.MaxSendMessageSize = maximumMessageSize;
3935
});
4036
if (options.Mode == MessagingMode.Server || options.Mode == MessagingMode.Both)
4137
{
@@ -144,9 +140,6 @@ public static void Configure(ConfigurationServices configurationServices, Messag
144140
return handler;
145141
}).ConfigureChannel(opts =>
146142
{
147-
opts.MaxReceiveMessageSize = maximumMessageSize;
148-
opts.MaxSendMessageSize = maximumMessageSize;
149-
150143
if (options.Url.Scheme == "dns")
151144
{
152145
opts.Credentials = ChannelCredentials.SecureSsl;

shared/src/EMBC.Utilities/Csv/CsvConverter.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ private static void CreateRows<T>(IEnumerable<T> list, TextWriter sw, string quo
3535
}
3636
}
3737

38-
private static string Quote(object value, string quoteIdentifier) =>
39-
$"{quoteIdentifier}{Escape(value ?? string.Empty, quoteIdentifier)}{quoteIdentifier}";
40-
41-
private static string Escape(object value, string quoteIdentifier) =>
42-
(quoteIdentifier switch
43-
{
44-
"\"" => value.ToString().Replace("\"", "\"\""),
45-
"'" => value.ToString().Replace("'", "''"),
46-
_ => value.ToString()
47-
}).Replace("\r", string.Empty).Replace("\n", string.Empty);
38+
private static string Quote(object value, string quoteIdentifier)
39+
{
40+
if (value == null) return string.Empty;
41+
return quoteIdentifier + value + quoteIdentifier;
42+
}
4843

4944
public static void CreateCSV<T>(this IEnumerable<T> list, string filePath)
5045
{

0 commit comments

Comments
 (0)