Exemple #1
0
        public async Task <ActionResult <AggregationAnalysisResponse> > GetLanguageFrequency([FromRoute] Guid jobId)
        {
            _eventTracker.TrackInfo("GetLanguageFrequency", $"User '{User.Identity.Name}' requested language frequency for job '{jobId}'");
            if (!await _authorizationService.IsUserAuthorizedToSeeJob(User.Identity.Name, jobId))
            {
                _eventTracker.TrackInfo("GetLanguageFrequency", $"User '{User.Identity.Name}' is not authorized to see job '{jobId}'");
                return(Unauthorized());
            }

            var analysisResult = await _getAnalysisService.GetLanguageFrequency(jobId);

            var analysisResponse = AggregationAnalysisResponse.FromModel(analysisResult);

            return(Ok(analysisResponse));
        }
Exemple #2
0
        public async Task <ActionResult <AggregationAnalysisResponse> > GetAuthorFrequency([FromRoute] Guid jobId)
        {
            _eventTracker.TrackInfo("GetAuthorFrequency", $"User '{User.Identity.Name}' requested author frequency for job '{jobId}'");
            if (!await _authorizationService.IsUserAuthorizedToSeeJob(User.Identity.Name, jobId))
            {
                _eventTracker.TrackInfo("GetAuthorFrequency", $"User '{User.Identity.Name}' is not authorized to see job '{jobId}'");
                return(Unauthorized());
            }

            var analysisResult = await _getAnalysisService.GetAuthorFrequency(jobId);

            analysisResult.MapResult.Remove("0"); // Artificial author id for posts, where no author is defined
            var analysisResponse = AggregationAnalysisResponse.FromModel(analysisResult);

            return(Ok(analysisResponse));
        }
Exemple #3
0
        public async Task <ActionResult <AggregationAnalysisResponse> > GetJobAnalysisAggregation([FromRoute] Guid jobId, [FromBody] GetAggregationAnalysisRequest analysisRequest)
        {
            _eventTracker.TrackInfo("GetJobAnalysisAggregation", $"User '{User.Identity.Name}' requested aggregation analysis", analysisRequest);
            if (!await _authorizationService.IsUserAuthorizedToSeeJob(User.Identity.Name, jobId))
            {
                _eventTracker.TrackInfo("GetJobAnalysisAggregation", $"User '{User.Identity.Name}' is not authorized to see job '{jobId}'");
                return(Unauthorized());
            }

            try
            {
                var analysisResult = await _getAnalysisService.GetAggregationAnalysis(jobId, analysisRequest.AnalyserId,
                                                                                      analysisRequest.AnalysisProperty);

                var analysisResponse = AggregationAnalysisResponse.FromModel(analysisResult);

                return(Ok(analysisResponse));
            }
            catch (GetAnalysisService.GetAnalysisException e)
            {
                _eventTracker.TrackError("GetAggregationAnalysis", e.Message, analysisRequest);
                return(Ok(AggregationAnalysisResponse.Empty()));
            }
        }