Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9635 for branches


Ignore:
Timestamp:
06/17/13 11:51:20 (11 years ago)
Author:
pfleck
Message:

#2030:
Restructured and simplified GetTaskByIdAndLastStateLogSlaveIdQuery.
Sorted StateLogs in GetLightweightTasksQuery.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/OptimizedHiveDao.cs

    r9634 r9635  
    5656
    5757    private static readonly Func<HiveDataContext, Guid, IQueryable<Tuple<Task, Guid?>>> GetTaskByIdAndLastStateLogSlaveIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
    58        from t in db.Tasks
    59        join sl in db.StateLogs on t.TaskId equals sl.TaskId
    60        where t.TaskId == taskId
    61        orderby sl.DateTime descending
    62        group sl by t into logs
    63        select new Tuple<Task, Guid?>(logs.Key, logs.First().SlaveId)
     58      from t in db.Tasks
     59      let lastStateLog = t.StateLogs.OrderByDescending(sl => sl.DateTime).FirstOrDefault()
     60      where t.TaskId == taskId
     61      select new Tuple<Task, Guid?>(t, lastStateLog != null ? lastStateLog.SlaveId : null)
    6462    );
    6563
     
    10098          ExecutionTime = TimeSpan.FromMilliseconds(task.ExecutionTimeMs),
    10199          ParentTaskId = task.ParentTaskId,
    102           StateLog = task.StateLogs.Select(sl => ConvertStateLog(sl)).ToList(),
     100          StateLog = task.StateLogs.OrderBy(sl => sl.DateTime).Select(sl => ConvertStateLog(sl)).ToList(),
    103101          State = ConvertTaskState(task.State),
    104102          Command = ConvertCommand(task.Command),
Note: See TracChangeset for help on using the changeset viewer.