public Index_FailureGroupsViewIndex() { this.ViewText = @"from doc in docs.FailedMessages where doc.Status == 1 select new { doc = doc, failureTimes = doc.ProcessingAttempts.Select(x => x.FailureDetails.TimeOfFailure) } into this0 from failureGroup in this0.doc.FailureGroups select new { Id = failureGroup.Id, Title = failureGroup.Title, Count = 1, First = DynamicEnumerable.Min(this0.failureTimes), Last = DynamicEnumerable.Max(this0.failureTimes), Type = failureGroup.Type } from result in results group result by new { Id = result.Id, Title = result.Title, Type = result.Type } into g select new { Id = g.Key.Id, Title = g.Key.Title, Count = Enumerable.Sum(g, x => ((int)x.Count)), First = DynamicEnumerable.Min(g, x0 => ((DateTime)x0.First)), Last = DynamicEnumerable.Max(g, x1 => ((DateTime)x1.Last)), Type = g.Key.Type }"; this.ForEntityNames.Add("FailedMessages"); this.AddMapDefinition(docs => from doc in ((IEnumerable <dynamic>)docs) where string.Equals(doc["@metadata"]["Raven-Entity-Name"], "FailedMessages", System.StringComparison.InvariantCultureIgnoreCase) where doc.Status == 1 select new { doc = doc, failureTimes = doc.ProcessingAttempts.Select((Func <dynamic, dynamic>)(x => x.FailureDetails.TimeOfFailure)), __document_id = doc.__document_id } into this0 from failureGroup in ((IEnumerable <dynamic>)this0.doc.FailureGroups) select new { Id = failureGroup.Id, Title = failureGroup.Title, Count = 1, First = DynamicEnumerable.Min(this0.failureTimes), Last = DynamicEnumerable.Max(this0.failureTimes), Type = failureGroup.Type, __document_id = this0.__document_id }); this.ReduceDefinition = results => from result in results group result by new { Id = result.Id, Title = result.Title, Type = result.Type } into g select new { Id = g.Key.Id, Title = g.Key.Title, Count = Enumerable.Sum(g, (Func <dynamic, int>)(x => ((int)x.Count))), First = DynamicEnumerable.Min(g, (Func <dynamic, DateTime>)(x0 => ((DateTime)x0.First))), Last = DynamicEnumerable.Max(g, (Func <dynamic, DateTime>)(x1 => ((DateTime)x1.Last))), Type = g.Key.Type }; this.GroupByExtraction = result => new { Id = result.Id, Title = result.Title, Type = result.Type }; this.AddField("Id"); this.AddField("Title"); this.AddField("Count"); this.AddField("First"); this.AddField("Last"); this.AddField("Type"); this.AddQueryParameterForMap("__document_id"); this.AddQueryParameterForMap("Id"); this.AddQueryParameterForMap("Title"); this.AddQueryParameterForMap("Type"); this.AddQueryParameterForReduce("__document_id"); this.AddQueryParameterForReduce("Id"); this.AddQueryParameterForReduce("Title"); this.AddQueryParameterForReduce("Type"); }
public static dynamic Max(this IGrouping <dynamic, dynamic> self, Func <dynamic, bool> predicate) { return(DynamicEnumerable.Max(self, predicate)); }
public static dynamic Max(this IGrouping <dynamic, dynamic> self) { return(DynamicEnumerable.Max(self)); }
public Index_RetryBatches_ByStatus_ReduceInitialBatchSize() { this.ViewText = @"from doc in docs.RetryBatches select new { RequestId = doc.RequestId, RetryType = doc.RetryType, HasStagingBatches = doc.Status == 2, HasForwardingBatches = doc.Status == 3, InitialBatchSize = doc.InitialBatchSize, Originator = doc.Originator, Classifier = doc.Classifier, StartTime = doc.StartTime, Last = doc.Last } from result in results group result by new { RequestId = result.RequestId, RetryType = result.RetryType } into g select new { RequestId = g.Key.RequestId, RetryType = g.Key.RetryType, Originator = (DynamicEnumerable.FirstOrDefault(g)).Originator, HasStagingBatches = Enumerable.Any(g, x => x.HasStagingBatches), HasForwardingBatches = Enumerable.Any(g, x0 => x0.HasForwardingBatches), InitialBatchSize = Enumerable.Sum(g, x1 => ((int)x1.InitialBatchSize)), StartTime = (DynamicEnumerable.FirstOrDefault(g)).StartTime, Last = DynamicEnumerable.Max(g, x2 => ((DateTime)x2.Last)), Classifier = (DynamicEnumerable.FirstOrDefault(g)).Classifier }"; this.ForEntityNames.Add("RetryBatches"); this.AddMapDefinition(docs => from doc in ((IEnumerable <dynamic>)docs) where string.Equals(doc["@metadata"]["Raven-Entity-Name"], "RetryBatches", System.StringComparison.InvariantCultureIgnoreCase) select new { RequestId = doc.RequestId, RetryType = doc.RetryType, HasStagingBatches = doc.Status == 2, HasForwardingBatches = doc.Status == 3, InitialBatchSize = doc.InitialBatchSize, Originator = doc.Originator, Classifier = doc.Classifier, StartTime = doc.StartTime, Last = doc.Last, __document_id = doc.__document_id }); this.ReduceDefinition = results => from result in results group result by new { RequestId = result.RequestId, RetryType = result.RetryType } into g select new { RequestId = g.Key.RequestId, RetryType = g.Key.RetryType, Originator = (DynamicEnumerable.FirstOrDefault(g)).Originator, HasStagingBatches = Enumerable.Any(g, (Func <dynamic, bool>)(x => x.HasStagingBatches)), HasForwardingBatches = Enumerable.Any(g, (Func <dynamic, bool>)(x0 => x0.HasForwardingBatches)), InitialBatchSize = Enumerable.Sum(g, (Func <dynamic, int>)(x1 => ((int)x1.InitialBatchSize))), StartTime = (DynamicEnumerable.FirstOrDefault(g)).StartTime, Last = DynamicEnumerable.Max(g, (Func <dynamic, DateTime>)(x2 => ((DateTime)x2.Last))), Classifier = (DynamicEnumerable.FirstOrDefault(g)).Classifier }; this.GroupByExtraction = result => new { RequestId = result.RequestId, RetryType = result.RetryType }; this.AddField("RequestId"); this.AddField("RetryType"); this.AddField("Originator"); this.AddField("HasStagingBatches"); this.AddField("HasForwardingBatches"); this.AddField("InitialBatchSize"); this.AddField("StartTime"); this.AddField("Last"); this.AddField("Classifier"); this.AddQueryParameterForMap("RequestId"); this.AddQueryParameterForMap("RetryType"); this.AddQueryParameterForMap("InitialBatchSize"); this.AddQueryParameterForMap("Originator"); this.AddQueryParameterForMap("Classifier"); this.AddQueryParameterForMap("StartTime"); this.AddQueryParameterForMap("Last"); this.AddQueryParameterForMap("__document_id"); this.AddQueryParameterForReduce("RequestId"); this.AddQueryParameterForReduce("RetryType"); this.AddQueryParameterForReduce("InitialBatchSize"); this.AddQueryParameterForReduce("Originator"); this.AddQueryParameterForReduce("Classifier"); this.AddQueryParameterForReduce("StartTime"); this.AddQueryParameterForReduce("Last"); this.AddQueryParameterForReduce("__document_id"); }