Skip to content

Commit

Permalink
feat: add GetLastChangedRecords to retrieve all records for a given id
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Jan 15, 2019
1 parent 47708c2 commit cabec63
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ public abstract class LastChangedListConnectedProjection : ConnectedProjection<L

protected LastChangedListConnectedProjection(AcceptType[] supportedAcceptTypes) => _supportedAcceptTypes = supportedAcceptTypes;

protected async Task<IEnumerable<LastChangedRecord>> GetLastChangedRecords(
string identifier,
LastChangedListContext context,
CancellationToken cancellationToken)
{
var attachedRecords = new List<LastChangedRecord>();

// Create a record for every type that our API accepts.
foreach (var acceptType in _supportedAcceptTypes)
{
var shortenedApplicationType = acceptType.ToString().ToLowerInvariant();
var id = $"{identifier}.{shortenedApplicationType}";

var record = await context
.LastChangedList
.FindAsync(id, cancellationToken: cancellationToken);

if (record != null)
attachedRecords.Add(record);
}

return attachedRecords;
}

protected async Task<IEnumerable<LastChangedRecord>> GetLastChangedRecordsAndUpdatePosition(
string identifier,
long position,
Expand Down

0 comments on commit cabec63

Please sign in to comment.