Esempio n. 1
0
        private async Task Run(ParkrunQuestionnaireResponsesMessage message, IAsyncCollector <UpdateParkrunFeatures.Request> requests, CancellationToken cancellationToken)
        {
            var aggregation = _aggregator.Aggregate(message);

            var request = _mapper.Map <UpdateParkrunFeatures.Request>(aggregation);

            await requests.AddAsync(request, cancellationToken)
            .ConfigureAwait(false);
        }
Esempio n. 2
0
        public static async Task Run(
            [QueueTrigger(QueueNames.AggregateQuestionnaireResponses, Connection = "AzureWebJobsStorage")]
            ParkrunQuestionnaireResponsesMessage message,
            [Queue(QueueNames.UpdateParkrunFeatures, Connection = "AzureWebJobsStorage")] IAsyncCollector <UpdateParkrunFeatures.Request> requests,
            ILogger logger, CancellationToken cancellationToken)
        {
            var func = Container.Instance.Resolve <QuestionnaireResponseAggregatorQueueFunction>(logger);

            await func.Run(message, requests, cancellationToken)
            .ConfigureAwait(false);
        }
        public ParkrunQuestionnaireResponseAggregation Aggregate(ParkrunQuestionnaireResponsesMessage message)
        {
            var wheelchairFriendly =
                AggregateWheelchairFriendlyAnswers(message.Responses.Select(y => y.WheelchairFriendlyAnswer));
            var buggyFriendly        = AggregateBuggyFriendlyAnswers(message.Responses.Select(y => y.BuggyFriendlyAnswer));
            var terrainTypes         = AggregateTerrainAnswers(message.Responses.Select(y => y.TerrainAnswer));
            var hasToilets           = AggregateHasToiletsAnswers(message.Responses.Select(y => y.HasToiletsAnswer));
            var dogsAllowed          = AggregateDogsAllowedAnswers(message.Responses.Select(y => y.DogsAllowedAnswer));
            var hasCafe              = AggregateHasCafeAnswers(message.Responses.Select(y => y.CafeAnswer));
            var hasPostRunCoffee     = AggregatePostRunCoffeeAnswers(message.Responses.Select(y => y.PostRunCoffeeAnswer));
            var hasDrinkingFountains =
                AggregateDrinkingFountainsAnswers(message.Responses.Select(y => y.DrinkingFountainsAnswer));
            var hasChangingRooms = AggregateChangingRoomsAnswers(message.Responses.Select(y => y.ChangingRoomsAnswer));
            var hasLockers       = AggregateLockersAvailableAnswers(message.Responses.Select(y => y.LockersAvailableAnswer));
            var hasShowers       = AggregateShowersAvailableAnswers(message.Responses.Select(y => y.ShowersAvailableAnswer));
            var carParking       = AggregateCarParkingAnswers(message.Responses.Select(y => y.CarParkingAnswer));

            var cycleParking = AggregateCycleParkingAnswers(message.Responses.Select(y => y.CycleParkingAnswer));
            var hasBagDrop   = AggregateBagDropAnswers(message.Responses.Select(y => y.BagDropAnswer));
            var hasBabyChangingFacilities =
                AggregateBabyChangingFacilitiesAnswers(message.Responses.Select(y => y.BabyChangingFacilitiesAnswer));
            var visuallyImpairedFriendly =
                AggregateVisuallyImpairedFriendlyAnswers(
                    message.Responses.Select(y => y.VisuallyImpairedFriendlyAnswer));
            var buggyTypes = AggregateTypeOfBuggyAnswers(message.Responses.Select(y => y.TypeOfBuggyAnswer));

            return(new ParkrunQuestionnaireResponseAggregation()
            {
                WebsiteDomain = message.Responses.First().WebsiteDomain,
                WebsitePath = message.Responses.First().WebsitePath,
                WheelchairFriendly = wheelchairFriendly,
                BuggyFriendly = buggyFriendly,
                VisuallyImpairedFriendly = visuallyImpairedFriendly,
                Toilets = hasToilets,
                DogsAllowed = dogsAllowed,
                Cafe = hasCafe,
                PostRunCoffee = hasPostRunCoffee,
                DrinkingFountain = hasDrinkingFountains,
                ChangingRooms = hasChangingRooms,
                Lockers = hasLockers,
                Showers = hasShowers,
                BagDrop = hasBagDrop,
                BabyChangingFacilities = hasBabyChangingFacilities,
                CarParking = carParking.hasParking,
                CarParkingOptions = carParking.options,
                CycleParking = cycleParking.hasParking,
                CycleParkingOptions = cycleParking.options,
                RecommendedBuggy = buggyTypes,
                Terrain = terrainTypes,
            });
        }
        private async Task Run(IAsyncCollector <ParkrunQuestionnaireResponsesMessage> messageCollector)
        {
            var responses = await _downloader.DownloadQuestionnaireResponsesAsync()
                            .ConfigureAwait(false);

            foreach (var group in responses.GroupBy(x => new { x.WebsiteDomain, x.WebsitePath }))
            {
                var message = new ParkrunQuestionnaireResponsesMessage
                {
                    WebsiteDomain = group.Key.WebsiteDomain,
                    WebsitePath   = group.Key.WebsitePath,
                    Responses     = group.ToArray()
                };

                await messageCollector.AddAsync(message)
                .ConfigureAwait(false);
            }
        }