Exemplo n.º 1
0
        public async Task <IActionResult> GetAll([FromQuery] SearchInputModel filter, [FromQuery] int?perPage, [FromQuery] int page = 1, bool withTotal = false)
        {
            //未指定、あるいは1000件以上であれば、1000件に指定
            var pageCount = (perPage.HasValue && perPage.Value < 1000) ? perPage.Value : 1000;

            var experiments = experimentRepository
                              .GetAllWithOrderby(x => x.Id, false)
                              .Include(x => x.Template)
                              .Include(x => x.DataSet)
                              .Include(x => x.ExperimentPreprocess).ThenInclude(x => x.TrainingHistory).ThenInclude(x => x.DataSet)
                              .Include(x => x.TrainingHistory).ThenInclude(x => x.DataSet)
                              .SearchLong(d => d.Id, filter.Id)
                              .SearchString(d => d.Name, filter.Name)
                              .SearchTime(d => d.CreatedAt, filter.StartedAt);

            if (withTotal)
            {
                SetTotalCountToHeader(experiments.Count());
            }

            var result = new List <IndexOutputModel>();

            foreach (var x in experiments.Paging(page, pageCount))
            {
                var preprocessStatus = await UpdateStatus(x.ExperimentPreprocess?.TrainingHistory);

                var trainingStatus = await UpdateStatus(x.TrainingHistory);

                var status = GetExperimentStatus(preprocessStatus, trainingStatus);
                result.Add(new IndexOutputModel(x, status.ToString()));
            }

            return(JsonOK(result));
        }