public IEnumerable <TagDto> SearchWeightedTags(string tag, string setKey) { MongoTagsMonitoringApi monitoringApi = MonitoringApi; return(monitoringApi.DbContext.JobGraph .OfType <SetDto>() .Find(Builders <SetDto> .Filter.Regex(x => x.Key, new BsonRegularExpression($"tags<.*"))) .ToList() .Select(x => new TagDto { Amount = 1, Tag = x.Value, Percentage = 5 })); //Dictionary<string, List<SetDto>> tto = GetTags(setKey); //double ttot = tto.Sum(k => k.Value.Count); //IEnumerable<TagDto> res = tto.Select(k => new TagDto //{ // Amount = k.Value.Count, // Tag = k.Key, // Percentage = Convert.ToInt32(Math.Round(k.Value.Count / ttot * 100)) //}); //return res; }
public long GetTagsCount() { MongoTagsMonitoringApi monitoringApi = MonitoringApi; return(monitoringApi.DbContext.JobGraph .OfType <SetDto>() .Find(Builders <SetDto> .Filter.Regex(x => x.Key, new BsonRegularExpression($"tags<.*"))) .CountDocuments()); }
private List <JobDto> GetJobs(string[] tags, int maxTags, int from) { MongoTagsMonitoringApi monitoringApi = MonitoringApi; Dictionary <string, List <SetDto> > tto = GetTags("tags", tags.FirstOrDefault()); List <ObjectId> values = tags.SelectMany(x => tto[x.Replace("tags:", string.Empty)]).Select(w => new ObjectId(w.Key.Replace("tags:", string.Empty).Replace($"<{w.Value}>", string.Empty))).ToList(); List <JobDto> jobs = monitoringApi.DbContext .JobGraph .OfType <JobDto>() .Find(Builders <JobDto> .Filter.In(x => x.Id, values)) .Skip(from) .Limit(maxTags) .ToList(); return(jobs); }
private Dictionary <string, List <SetDto> > GetTags(string setKey, string tagName) { MongoTagsMonitoringApi monitoringApi = MonitoringApi; Dictionary <string, List <SetDto> > tto = monitoringApi.DbContext.JobGraph .OfType <SetDto>() .Find(Builders <SetDto> .Filter.Regex(x => x.Key, new BsonRegularExpression($"{setKey}:.*<{tagName.Replace("tags:", string.Empty)}>"))) .ToList() .GroupBy(x => x.Value) .Select(x => new { TagName = x.Key, SetList = x.ToList() }) .ToDictionary(k => k.TagName, k => k.SetList); return(tto); }