Skip to content

Commit

Permalink
fix date range issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cammj committed May 10, 2024
1 parent 596017d commit 0e5d219
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private static async Task<HashSet<string>> GetTenantSimulations(GraphServiceClie
var SimulationExistingTableItem = await tableClient.GetEntityIfExistsAsync<TableEntity>("Simulations", sim.Id);

// For determining the last user sync
DateTime LastUserSync = DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc);
DateTime LastUserSync = DateTime.SpecifyKind(new DateTime(1986,1,1), DateTimeKind.Utc);
if (SimulationExistingTableItem.HasValue && SimulationExistingTableItem.Value.ContainsKey("LastUserSync"))
LastUserSync = DateTime.SpecifyKind(DateTime.Parse(SimulationExistingTableItem.Value["LastUserSync"].ToString()), DateTimeKind.Utc);

Expand Down Expand Up @@ -479,12 +479,12 @@ private static async Task<bool> ShouldSyncUser(string id)
var UserTableItem = await tableClient.GetEntityIfExistsAsync<TableEntity>("Users", id);

// Get last sync time
DateTime? LastUserSync = null;
DateTime LastUserSync = new DateTime(1986,1,1);
if (UserTableItem.HasValue && UserTableItem.Value.ContainsKey("LastUserSync"))
LastUserSync = DateTime.SpecifyKind(DateTime.Parse(UserTableItem.Value["LastUserSync"].ToString()), DateTimeKind.Utc);

// If no sync or days is older than a week
if (LastUserSync is null || LastUserSync.Value < DateTime.UtcNow.AddDays(-7))
if (LastUserSync < DateTime.UtcNow.AddDays(-7))
return true;

// Add to userSyncList so we don't need to check again
Expand Down

0 comments on commit 0e5d219

Please sign in to comment.