Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix to apply candidate sync job #1433

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading