- Timestamp:
- 01/29/18 17:38:50 (7 years ago)
- Location:
- branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs
r15577 r15666 28 28 public class ProjectDao : GenericDao<Guid, Project> { 29 29 public ProjectDao(DataContext dataContext) : base(dataContext) { } 30 31 public class ProjectStats { 32 public Guid ProjectId { get; set; } 33 public int Cores { get; set; } 34 public int Memory { get; set; } 35 } 30 36 31 37 public override Project GetById(Guid id) { … … 70 76 } 71 77 78 public IEnumerable<ProjectStats> GetUsageStatsPerProject() { 79 return DataContext.ExecuteQuery<ProjectStats>(GetUsageStatsPerProjectQueryString).ToList(); 80 } 81 82 public IEnumerable<ProjectStats> GetAvailabilityStatsPerProject() { 83 return DataContext.ExecuteQuery<ProjectStats>(GetAvailabilityStatsPerProjectQueryString).ToList(); 84 } 85 72 86 #region Compiled queries 73 87 private static readonly Func<DataContext, Guid, Project> GetByIdQuery = … … 79 93 80 94 #region String queries 95 private const string GetUsageStatsPerProjectQueryString = @" 96 SELECT j.ProjectId, SUM(t.CoresNeeded) AS Cores, SUM(t.MemoryNeeded) AS Memory 97 FROM [Task] t, [Job] j 98 WHERE t.TaskState = 'Calculating' 99 AND t.JobId = j.JobId 100 GROUP BY j.ProjectId 101 "; 102 103 private const string GetAvailabilityStatsPerProjectQueryString = @" 104 WITH rtree AS 105 ( 106 SELECT ResourceId, ParentResourceId 107 FROM [Resource] 108 UNION ALL 109 SELECT rt.ResourceId, r.ParentResourceId 110 FROM [Resource] r 111 JOIN rtree rt ON rt.ParentResourceId = r.ResourceId 112 ) 113 SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory 114 FROM rtree, [AssignedProjectResource] apr, [Resource] res 115 WHERE rtree.ResourceId = res.ResourceId 116 AND res.ResourceType = 'Slave' 117 AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating') 118 AND rtree.ParentResourceId = apr.ResourceId 119 GROUP BY apr.ProjectId 120 UNION 121 SELECT apr.ProjectId, SUM(res.Cores) AS Cores, SUM(res.Memory) AS Memory 122 FROM [AssignedProjectResource] apr, [Resource] res 123 WHERE apr.ResourceId = res.ResourceId 124 AND res.ResourceType = 'Slave' 125 AND (res.SlaveState = 'Idle' OR SlaveState = 'Calculating') 126 GROUP BY apr.ProjectId 127 "; 128 81 129 private const string GetUsageGrantedProjectsForUserQueryString = @" 82 130 SELECT DISTINCT p.* -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r15644 r15666 93 93 94 94 #region String queries 95 private const string Get ParentTasksQueryString= @"96 SELECT t.* FROM [Task] t, [Job] j , [AssignedJobResource] ajr97 WHERE t.IsParentTask = 198 AND t.TaskState = ' Waiting'95 private const string GetCalculatingChildTasksByProjectId = @" 96 SELECT t.* FROM [Task] t, [Job] j 97 WHERE t.IsParentTask = 0 98 AND t.TaskState = 'Calculating' 99 99 AND t.JobId = j.JobId 100 AND j.JobId = ajr.JobId 101 AND t.FinishWhenChildJobsFinished = 1 102 ... TODO (not necessary) 100 AND j.ProjectId = {0} 101 ORDER BY j.ProjectId 103 102 "; 104 103 private const string GetWaitingTasksQueryString = @"
Note: See TracChangeset
for help on using the changeset viewer.