Beispiel #1
0
        private void FillTaskList()
        {
            // Fill task list if needed
            for (int i = 0; i < Math.Min(ConcurrentRecommendationsLimit - _runningTasks.Count(), _queue.QueuedCount); i++)
            {
                var queuedRecommendation = _queue.GetUnstartedRecommendation();

                if (queuedRecommendation is null || _storage.GetRecommendationStatus(queuedRecommendation.Id) != Database.RecommendationStatus.Queued)
                {
                    break;
                }

                _storage.SetRecommendationStatus(queuedRecommendation.Id, Database.RecommendationStatus.InProgress);

                var task = _recommendationEngine.GenerateRecommendation(queuedRecommendation.RecommendationParameters);
                _runningTasks.Add(new RecommendationTask
                {
                    Task = task,
                    QueuedRecommendationId = queuedRecommendation.Id
                });
            }
        }
        public ActionResult <Database.RecommendationStatus> Status(int queuedRecommendationId)
        {
            var status = _storage.GetRecommendationStatus(queuedRecommendationId);

            return(status);
        }