Skip to content

Commit

Permalink
rollback whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
martyn-w committed Jan 9, 2025
1 parent 4de45ac commit eccb8dc
Showing 1 changed file with 50 additions and 49 deletions.
99 changes: 50 additions & 49 deletions GetIntoTeachingApi/Services/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using GetIntoTeachingApi.Models;
using GetIntoTeachingApi.Models.Crm;
using GetIntoTeachingApi.Models.GetIntoTeaching;
using GetIntoTeachingApi.Utils;
using GetIntoTeachingApi.Utils;
using Microsoft.EntityFrameworkCore;
using MoreLinq;
using NetTopologySuite.Geometries;
Expand All @@ -16,8 +16,8 @@
namespace GetIntoTeachingApi.Services
{
public class Store : IStore
{
public static readonly TimeSpan TeachingEventArchiveSize = TimeSpan.FromDays(31 * 12);
{
public static readonly TimeSpan TeachingEventArchiveSize = TimeSpan.FromDays(31 * 12);
private static readonly HashSet<string> FailedPostcodeLookupCache = new HashSet<string>();
private readonly GetIntoTeachingDbContext _dbContext;
private readonly IGeocodeClientAdapter _geocodeClient;
Expand All @@ -39,9 +39,9 @@ public Store(
_env = env;
}

public static void ClearFailedPostcodeLookupCache()
{
FailedPostcodeLookupCache.Clear();
public static void ClearFailedPostcodeLookupCache()
{
FailedPostcodeLookupCache.Clear();
}

public async Task<string> CheckStatusAsync()
Expand Down Expand Up @@ -69,19 +69,19 @@ public async Task SyncAsync()
}

public IQueryable<Country> GetCountries()
{
{
return _dbContext.Countries.AsNoTracking().OrderBy(t => t.Id);
}

}

public IQueryable<TeachingSubject> GetTeachingSubjects()
{
{
return _dbContext.TeachingSubjects.AsNoTracking().OrderBy(t => t.Id);
}

}

public IQueryable<PickListItem> GetPickListItems(string entityName, string attributeName)
{
return _dbContext.PickListItems.AsNoTracking().Where(t => t.EntityName == entityName && t.AttributeName == attributeName).OrderBy(t => t.Id);
}
}

public async Task<PrivacyPolicy> GetLatestPrivacyPolicyAsync()
{
Expand Down Expand Up @@ -127,9 +127,9 @@ public async Task<IEnumerable<TeachingEvent>> SearchTeachingEventsAsync(Teaching
request.StatusIds.Contains(te.StatusId));
}

if (request.Online != null)
{
teachingEvents = teachingEvents.Where(te => te.IsOnline == request.Online);
if (request.Online != null)
{
teachingEvents = teachingEvents.Where(te => te.IsOnline == request.Online);
}

if (request.Radius == null || request.Postcode == null)
Expand Down Expand Up @@ -157,17 +157,17 @@ public IQueryable<TeachingEventBuilding> GetTeachingEventBuildings()

public async Task SaveAsync<T>(IEnumerable<T> models)
where T : BaseModel
{
{
var existingIds = _dbContext.Set<T>().Select(m => m.Id);

_dbContext.UpdateRange(models.Where(m => existingIds.Contains(m.Id)));
await _dbContext.AddRangeAsync(models.Where(m => !existingIds.Contains(m.Id)));
await _dbContext.SaveChangesAsync();
}

public async Task SaveAsync<T>(T model)
}

public async Task SaveAsync<T>(T model)
where T : BaseModel
{
{
await SaveAsync(new T[] { model });
}

Expand Down Expand Up @@ -217,12 +217,12 @@ private async Task SyncTeachingEvents()
var teachingEvents = _crm.GetTeachingEvents(afterDate).ToList();
var teachingEventBuildings = _dbContext.TeachingEventBuildings.ToList();

foreach (var te in teachingEvents)
{
if (te.BuildingId != null)
{
te.Building = teachingEventBuildings.FirstOrDefault(b => b.Id == te.BuildingId);
}
foreach (var te in teachingEvents)
{
if (te.BuildingId != null)
{
te.Building = teachingEventBuildings.FirstOrDefault(b => b.Id == te.BuildingId);
}
}

await SyncModels(teachingEvents, _dbContext.TeachingEvents);
Expand Down Expand Up @@ -254,8 +254,8 @@ private async Task SyncPickListItems()
await SyncPickListItem("contact", "dfe_isadvisorrequiredos");
await SyncPickListItem("contact", "dfe_gitismlservicesubscriptionchannel");
await SyncPickListItem("contact", "dfe_gitiseventsservicesubscriptionchannel");
await SyncPickListItem("contact", "dfe_gitisttaservicesubscriptionchannel");
await SyncPickListItem("contact", "dfe_candidateapplystatus");
await SyncPickListItem("contact", "dfe_gitisttaservicesubscriptionchannel");
await SyncPickListItem("contact", "dfe_candidateapplystatus");
await SyncPickListItem("contact", "dfe_candidateapplyphase");

await SyncPickListItem("dfe_candidatequalification", "dfe_degreestatus");
Expand All @@ -266,23 +266,24 @@ private async Task SyncPickListItems()

await SyncPickListItem("msevtmgt_event", "dfe_event_type");
await SyncPickListItem("msevtmgt_event", "dfe_eventstatus");
await SyncPickListItem("msevtmgt_event", "dfe_eventregion");
await SyncPickListItem("msevtmgt_event", "dfe_eventregion");

await SyncPickListItem("msevtmgt_eventregistration", "dfe_channelcreation");

await SyncPickListItem("phonecall", "dfe_channelcreation");

await SyncPickListItem("dfe_servicesubscription", "dfe_servicesubscriptiontype");

await SyncPickListItem("dfe_applyapplicationform", "dfe_applyphase");
await SyncPickListItem("dfe_applyapplicationform", "dfe_applystatus");
await SyncPickListItem("dfe_applyapplicationform", "dfe_recruitmentyear");
await SyncPickListItem("dfe_applyapplicationchoice", "dfe_applicationchoicestatus");
await SyncPickListItem("dfe_applyreference", "dfe_referencefeedbackstatus");

await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelsource");
await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelservice");
await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelactivities");
await SyncPickListItem("dfe_servicesubscription", "dfe_servicesubscriptiontype");

await SyncPickListItem("dfe_applyapplicationform", "dfe_applyphase");
await SyncPickListItem("dfe_applyapplicationform", "dfe_applystatus");
await SyncPickListItem("dfe_applyapplicationform", "dfe_recruitmentyear");
await SyncPickListItem("dfe_applyapplicationchoice", "dfe_applicationchoicestatus");
await SyncPickListItem("dfe_applyreference", "dfe_referencefeedbackstatus");

await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelsource");
await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelservice");
await SyncPickListItem("dfe_contactchannelcreation", "dfe_creationchannelactivities");

}

private async Task SyncModels<T>(IEnumerable<T> models, IQueryable<T> dbSet)
Expand All @@ -307,8 +308,8 @@ private async Task SyncCountries()
_dbContext.UpdateRange(items.Where(t => existingIds.Contains(t.Id)));
await _dbContext.AddRangeAsync(items.Where(t => !existingIds.Contains(t.Id)));
await _dbContext.SaveChangesAsync();
}

}

private async Task SyncTeachingSubjects()
{
var items = _crm.GetTeachingSubjects();
Expand Down Expand Up @@ -349,9 +350,9 @@ private async Task<Point> CoordinateForPostcode(string postcode)
var sanitizedPostcode = Location.SanitizePostcode(postcode);

// Avoid the expense (Google API call) to re-check known lookup failures.
if (FailedPostcodeLookupCache.Contains(postcode))
{
return null;
if (FailedPostcodeLookupCache.Contains(postcode))
{
return null;
}

var coordinate = await GeocodePostcodeWithLocalLookup(sanitizedPostcode);
Expand All @@ -367,9 +368,9 @@ private async Task<Point> CoordinateForPostcode(string postcode)
{
await CacheLocation(postcode, coordinate);
}
else
{
FailedPostcodeLookupCache.Add(postcode);
else
{
FailedPostcodeLookupCache.Add(postcode);
}

return coordinate;
Expand Down

0 comments on commit eccb8dc

Please sign in to comment.