Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/13 09:56:11 (12 years ago)
Author:
pfleck
Message:

#2063:
ClientInfo facts are now generated correctly when resources are changed and new client dimensions are created.
Query username for statistics tables from user id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r9541 r9545  
    22using System.Linq;
    33using System.Transactions;
     4using HeuristicLab.Services.Access;
    45using HeuristicLab.Services.Hive.DataAccess;
    56
    67namespace HeuristicLab.Services.Hive {
    78  public class HiveStatisticsGenerator : IStatisticsGenerator {
     9
     10    private IUserManager userManager { get { return ServiceLocator.Instance.UserManager; } }
     11
    812    private static readonly TimeSpan SmallestTimeSpan = new TimeSpan(0, 5, 0);
    913
     
    6872          JobName = j.Name,
    6973          UserId = j.OwnerUserId,
    70           UserName = ""
     74          UserName = userManager.GetUserById(j.OwnerUserId).UserName
    7175        };
    7276
     
    8488        select new DimUser {
    8589          UserId = u,
    86           Name = ""
     90          Name = userManager.GetUserById(u).UserName
    8791        };
    8892
     
    140144      var lastFacts =
    141145        from cf in db.FactClientInfos
    142         group cf by cf.ClientId
    143           into grpFacts
    144           select grpFacts.OrderByDescending(x => x.Time).First();
     146        join r in db.DimClients on cf.ClientId equals r.Id
     147        group cf by r.ResourceId into grpFacts
     148        select new {
     149          ResourceId = grpFacts.Key,
     150          Fact = grpFacts.OrderByDescending(x => x.Time).First(),
     151        };
    145152
    146153      var slaves =
    147154        from s in db.Resources.OfType<Slave>()
    148155        join c in db.DimClients on s.ResourceId equals c.ResourceId
    149         join lcf in lastFacts on c.Id equals lcf.ClientId into joinCf
     156        join lcf in lastFacts on c.ResourceId equals lcf.ResourceId into joinCf
    150157        from cf in joinCf.DefaultIfEmpty()
     158        where c.ExpirationTime == null
    151159        select new {
    152160          Slave = s,
    153161          Client = c,
    154           LastFact = cf
     162          LastFact = cf != null ? cf.Fact : null
    155163        };
    156164
Note: See TracChangeset for help on using the changeset viewer.