Skip to content

Commit

Permalink
Merge pull request #1433 from DFE-Digital/bugfix-apply-candidate-sync…
Browse files Browse the repository at this point in the history
…-job

Bugfix to apply candidate sync job
  • Loading branch information
martyn-w authored Jun 6, 2024
2 parents 77f9cc6 + 22db962 commit cac7e8b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions GetIntoTeachingApi/GetIntoTeachingApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="CsvHelper" Version="31.0.4" />
<PackageReference Include="Flurl.Http.Newtonsoft" Version="0.9.1" />
<PackageReference Include="GeocodeSharp" Version="2.1.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.12" />
<PackageReference Include="Hangfire.Core" Version="1.8.12" />
Expand Down
10 changes: 7 additions & 3 deletions GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
using Flurl.Http.Newtonsoft;
using GetIntoTeachingApi.Adapters;
using GetIntoTeachingApi.Models;
using GetIntoTeachingApi.Models.Apply;
Expand All @@ -19,7 +20,7 @@ namespace GetIntoTeachingApi.Jobs
[AutomaticRetry(Attempts = 0)]
public class ApplyBackfillJob : BaseJob
{
public static readonly int PagesPerJob = 10;
public static readonly int PagesPerJob = 10;
private readonly IBackgroundJobClient _jobClient;
private readonly ILogger<ApplyBackfillJob> _logger;
private readonly IAppSettings _appSettings;
Expand Down Expand Up @@ -54,6 +55,9 @@ private static int EndPage(int startPage)

private async Task QueueCandidateSyncJobs(DateTime updatedSince, int startPage)
{
// Enforce use of the Newtonsoft Json serializer
FlurlHttp.Clients.UseNewtonsoft();

var request = Env.ApplyCandidateApiUrl
.AppendPathSegment("candidates")
.SetQueryParam("updated_since", updatedSince)
Expand Down
6 changes: 5 additions & 1 deletion GetIntoTeachingApi/Jobs/ApplySyncJob.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
using Flurl.Http.Newtonsoft;
using GetIntoTeachingApi.Models.Apply;
using GetIntoTeachingApi.Services;
using GetIntoTeachingApi.Utils;
Expand Down Expand Up @@ -53,6 +54,9 @@ public async Task RunAsync()

private async Task QueueCandidateSyncJobs()
{
// Enforce use of the Newtonsoft Json serializer
FlurlHttp.Clients.UseNewtonsoft();

var request = Env.ApplyCandidateApiUrl
.AppendPathSegment("candidates")
.SetQueryParam("updated_since", UpdatedSince())
Expand Down
3 changes: 2 additions & 1 deletion GetIntoTeachingApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"Sentry__Dsn": ""
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public async void Contract(string scenario)
await Setup();

var candidate = ConstructCandidate(ReadInput(scenario));

Assert.NotNull(candidate.Attributes.Email);

JobClient.Enqueue<ApplyCandidateSyncJob>(c => c.Run(candidate));

await AssertRequestMatchesSnapshot(scenario);
Expand Down
4 changes: 2 additions & 2 deletions GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@
<None Update="Fixtures\ukpostcodes_malformed_rows.csv.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Contracts\Input\ApplyCandidateApi\sync_with_a_new_candidaite_and_no_application_form.json">
<None Update="Contracts\Input\ApplyCandidateApi\sync_with_a_new_candidate_and_no_application_form.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Contracts\Input\ApplyCandidateApi\sync_with_a_new_candidaite_and_application_form.json">
<None Update="Contracts\Input\ApplyCandidateApi\sync_with_a_new_candidate_and_application_form.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Contracts\Input\ApplyCandidateApi\sync_with_an_existing_candidate_and_application_form.json">
Expand Down

0 comments on commit cac7e8b

Please sign in to comment.