コード例 #1
0
        public IQueryable<MetricValue> GetByMetricId( int metricId, MetricValueType? metricValueType = null )
        {
            // include MetricValuePartitions and each MetricValuePartition's MetricPartition so that MetricValuePartitionEntityIds doesn't have to lazy load
            var result = Get().Include( a => a.MetricValuePartitions.Select( b => b.MetricPartition ) ).Where( a => a.MetricId == metricId );
            if ( metricValueType.HasValue )
            {
                result = result.Where( a => a.MetricValueType == metricValueType );
            }

            return result.OrderBy( a => a.MetricValueDateTime );
        }
コード例 #2
0
        public IQueryable<MetricValue> GetByMetricId( int metricId, MetricValueType? metricValueType = null )
        {
            var metric = new MetricService( new RockContext() ).Get( metricId );

            var result = Get().Where( a => a.MetricId == metricId );
            if ( metricValueType.HasValue )
            {
                result = result.Where( a => a.MetricValueType == metricValueType );
            }

            return result.OrderBy( a => a.MetricValueDateTime );
        }
コード例 #3
0
        public IEnumerable<MetricSummary> GetSummary( string metricIdList, DateTime? startDate = null, DateTime? endDate = null, MetricValueType? metricValueType = null, int? entityTypeId = null, int? entityId = null )
        {
            List<int> metricIds = metricIdList.SplitDelimitedValues().AsIntegerList();
            var qry = Get().Where( a => metricIds.Contains( a.MetricId ) );
            if ( metricValueType.HasValue )
            {
                qry = qry.Where( a => a.MetricValueType == metricValueType );
            }

            if ( startDate.HasValue )
            {
                qry = qry.Where( a => a.MetricValueDateTime >= startDate.Value );
            }

            if ( endDate.HasValue )
            {
                qry = qry.Where( a => a.MetricValueDateTime < endDate.Value );
            }

            //// if an entityTypeId/EntityId filter was specified, and the entityTypeId is the same as the metrics.EntityTypeId, filter the values to the specified entityId
            //// Note: If a Metric or it's Metric Value doesn't have a context, include it regardless of Context setting
            if ( entityTypeId.HasValue )
            {
                if ( entityId.HasValue )
                {
                    qry = qry.Where( a => ( a.Metric.EntityTypeId == entityTypeId && a.EntityId == entityId ) || ( a.Metric.EntityTypeId == null) || ( a.EntityId == null ) );
                }
            }

            var groupBySum = qry
                .GroupBy( a => a.Metric )
                .Select( g => new
                {
                    MetricId = g.Key.Id,
                    MetricTitle = g.Key.Title,
                    YValueTotal = g.Sum( s => s.YValue )
                } ).ToList();

            return groupBySum.Select( s => new MetricSummary
            {
                MetricId = s.MetricId,
                MetricTitle = s.MetricTitle,
                YValueTotal = s.YValueTotal,
                StartDateTimeStamp = startDate.HasValue ? startDate.Value.ToJavascriptMilliseconds() : 0,
                EndDateTimeStamp = endDate.HasValue ? endDate.Value.ToJavascriptMilliseconds() : 0
            } );
        }
コード例 #4
0
ファイル: Metric.cs プロジェクト: John-Leitch/GenomeDotNet
 public MetricValue(MetricValueType type)
     : this()
 {
     Type = type;
 }
コード例 #5
0
 public MetricValue(MetricValueType type)
     : this()
 {
     Type = type;
 }
コード例 #6
0
        public IEnumerable<MetricSummary> GetSummary( string metricIdList, DateTime? startDate = null, DateTime? endDate = null, MetricValueType? metricValueType = null )
        {
            List<int> metricIds = metricIdList.SplitDelimitedValues().Select(a=> a.AsInteger()).ToList();
            var qry = Get().Where( a => metricIds.Contains( a.MetricId ) );
            if ( metricValueType.HasValue )
            {
                qry = qry.Where( a => a.MetricValueType == metricValueType );
            }

            if ( startDate.HasValue )
            {
                qry = qry.Where( a => a.MetricValueDateTime >= startDate.Value );
            }

            if ( endDate.HasValue )
            {
                qry = qry.Where( a => a.MetricValueDateTime < endDate.Value );
            }

            var groupBySum = qry
                .GroupBy( a => a.Metric )
                .Select( g => new
                {
                    MetricId = g.Key.Id,
                    MetricTitle = g.Key.Title,
                    YValueTotal = g.Sum( s => s.YValue )
                } ).ToList();

            return groupBySum.Select( s => new MetricSummary
            {
                MetricId = s.MetricId,
                MetricTitle = s.MetricTitle,
                YValueTotal = s.YValueTotal,
                StartDateTimeStamp = startDate.HasValue ? startDate.Value.ToJavascriptMilliseconds() : 0,
                EndDateTimeStamp = endDate.HasValue ? endDate.Value.ToJavascriptMilliseconds() : 0
            } );
        }