Skip to content

Commit

Permalink
fix: try to fix result streaming issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lynzrand committed Nov 6, 2020
1 parent 536f839 commit 14584e6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions coordinator/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ public async Task<ActionResult> DumpSuiteJobs(
distinct on (account)
*
from jobs
where test_suite = {suiteId.Num}
order by account, id desc
").AsAsyncEnumerable();
").Where((job) => job.TestSuite == suiteId)
.AsAsyncEnumerable();

Response.StatusCode = 200;
Response.ContentType = "application/csv";
const int flushInterval = 50;

const int flushInterval = 100;
Response.ContentType = "application/csv";
Response.StatusCode = 200;
await Response.StartAsync();

// write to body of response
var sw = new StreamWriter(Response.Body);
using var sw = new StreamWriter(Response.Body);
await using var swGuard = sw.ConfigureAwait(false);
var csvWriter = new CsvWriter(sw);
csvWriter.QuoteAllFields = true;

Expand All @@ -93,6 +95,7 @@ from jobs
counter++;
}
await sw.FlushAsync();

return new EmptyResult();
}

Expand Down

0 comments on commit 14584e6

Please sign in to comment.