예제 #1
0
        /// <inheritdoc/>
        public async Task <MultipleDocumentResult> GetActivityProfiles(Iri activityId, DateTimeOffset?since = null, CancellationToken cancellationToken = default)
        {
            var activity = await mediator.Send(GetActivityQuery.Create(activityId), cancellationToken);

            if (activity == null)
            {
                return(MultipleDocumentResult.Empty());
            }

            var documents = await mediator.Send(new GetActivityProfilesQuery()
            {
                ActivityId = activityId,
                Since      = since
            }, cancellationToken);

            if (!documents.Any())
            {
                return(MultipleDocumentResult.Empty());
            }

            var ids          = documents.Select(x => x.Key).ToHashSet();
            var lastModified = documents
                               .OrderByDescending(x => x.UpdatedAt)
                               .Select(x => x.UpdatedAt)
                               .FirstOrDefault();

            return(MultipleDocumentResult.Success(ids, lastModified));
        }
예제 #2
0
        public async Task <MultipleDocumentResult> GetActivityStates(Iri activityId, Agent agent, Guid?registration, DateTimeOffset?since = null, CancellationToken cancellationToken = default)
        {
            AgentEntity savedAgent = await mediator.Send(GetAgentQuery.Create(agent), cancellationToken);

            if (savedAgent == null)
            {
                return(MultipleDocumentResult.Empty());
            }

            var states = await mediator.Send(new GetActivityStatesQuery()
            {
                ActivityId   = activityId,
                AgentId      = savedAgent.AgentId,
                Registration = registration,
                Since        = since
            }, cancellationToken);

            if (!states.Any())
            {
                return(MultipleDocumentResult.Empty());
            }

            var keys         = states.Select(x => x.Key).ToHashSet();
            var lastModified = states.OrderByDescending(x => x.UpdatedAt)
                               .Select(x => x.UpdatedAt)
                               .FirstOrDefault();

            return(MultipleDocumentResult.Success(keys, lastModified));
        }
예제 #3
0
        public async Task <MultipleDocumentResult> GetAgentProfiles(Agent agent, DateTimeOffset?since = null, CancellationToken cancellationToken = default)
        {
            var agentEntity = await mediator.Send(GetAgentQuery.Create(agent), cancellationToken);

            if (agentEntity == null)
            {
                return(MultipleDocumentResult.Empty());
            }

            var profiles = await mediator.Send(GetAgentProfilesQuery.Create(agentEntity.AgentId, since), cancellationToken);

            if (!profiles.Any())
            {
                return(MultipleDocumentResult.Empty());
            }

            ICollection <string> ids          = profiles.Select(x => x.Key).ToHashSet();
            DateTimeOffset?      lastModified = profiles.OrderByDescending(x => x.UpdatedAt).Select(x => x.UpdatedAt).FirstOrDefault();

            return(MultipleDocumentResult.Success(ids, lastModified));
        }