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

ChallengeService updated to more frequently synchronize challenge data #44

Merged
merged 2 commits into from
Jul 28, 2022
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
24 changes: 11 additions & 13 deletions src/Gameboard.Api/Features/Challenge/ChallengeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,19 @@ public async Task<Challenge> Preview(NewChallenge model)

var spec = await Store.DbContext.ChallengeSpecs.FindAsync(model.SpecId);

//check preview cache, else mojo
var cachestate = _localcache.Get<string>(spec.ExternalId);

if (cachestate == null)
{
var state = await Mojo.PreviewGamespaceAsync(spec.ExternalId);

Transform(state);

cachestate = JsonSerializer.Serialize(state);

if (cachestate != null)
_localcache.Set(spec.ExternalId, cachestate, new TimeSpan(0, 60, 0));

}
// Null cache state means this is a new challenge we haven't retrieved yet
// Non-null cache state means this challenge has been retrieved before

// No matter what, retrieve the gamespace state, because we need to handle markdown changes
var state = await Mojo.PreviewGamespaceAsync(spec.ExternalId);
// Transform state markdown to become more readable
Transform(state);
cachestate = JsonSerializer.Serialize(state);
// Set the local cache to use this cache state for this challenge
if (cachestate != null)
_localcache.Set(spec.ExternalId, cachestate, new TimeSpan(0, 60, 0));

var challenge = Mapper.Map<Data.Challenge>(spec);

Expand Down
6 changes: 4 additions & 2 deletions src/Gameboard.Api/Features/Report/ReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ internal async Task<TicketDayGroup[]> GetTicketVolume(TicketReportFilter model)
var shift2Count = 0;
var outsideShiftCount = 0;
g.ToList().ForEach(ticket => {
if (ticket.Created.Hour >= 8 && ticket.Created.Hour < 16)
// Convert creation to local time
var ticketCreatedHour = ticket.Created.ToLocalTime().Hour;
if (ticketCreatedHour >= 8 && ticketCreatedHour < 16)
shift1Count += 1;
else if (ticket.Created.Hour >= 16 && ticket.Created.Hour < 23)
else if (ticketCreatedHour >= 16 && ticketCreatedHour < 23)
shift2Count += 1;
else
outsideShiftCount += 1;
Expand Down