QueryIntervalAsync() public method

Return values collected by time interval.
public QueryIntervalAsync ( Keen.Core.Query.QueryType queryType, string collection, string targetProperty, QueryTimeframe timeframe, Keen.Core.Query.QueryInterval interval = null, IEnumerable filters = null, string timezone = "" ) : Task>>
queryType Keen.Core.Query.QueryType Type of query to run.
collection string Name of event collection to query.
targetProperty string Name of property to analyse.
timeframe QueryTimeframe Specifies window of time from which to select events for analysis. May be absolute or relative.
interval Keen.Core.Query.QueryInterval The block size for partitioning the specified timeframe. Optional, may be null.
filters IEnumerable Filters to narrow down the events used in analysis. Optional, may be null.
timezone string The timezone to use when specifying a relative timeframe. Optional, may be blank.
return Task>>
コード例 #1
0
ファイル: QueryTest.cs プロジェクト: kidchenko/keen-sdk-net
        public async void SelectUnique_ValidRelativeInterval_Success()
        {
            var client = new KeenClient(settingsEnv);
            var prop = "field1";
            var interval = QueryInterval.EveryNMinutes(5);
            var timeframe = QueryRelativeTimeframe.ThisMinute();
            var resultl = "hello,goodbye,I'm late";
            IEnumerable<QueryIntervalValue<string>> result =
                new List<QueryIntervalValue<string>>() { new QueryIntervalValue<string>(resultl, DateTime.Now.AddMinutes(-5), DateTime.Now) };

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                queryMock = new Mock<IQueries>();
                queryMock.Setup(m => m.Metric(
                        It.Is<QueryType>(q => q == QueryType.SelectUnique()),
                        It.Is<string>(c => c == testCol),
                        It.Is<string>(p => p == prop),
                        It.Is<QueryRelativeTimeframe>(t => t == timeframe),
                        It.Is<QueryInterval>(i => i == interval),
                        It.Is<IEnumerable<QueryFilter>>(f => f == null),
                        It.Is<string>(t => t == "")
                        ))
                    .Returns(Task.FromResult(result));

                client.Queries = queryMock.Object;
            }

            var reply = (await client.QueryIntervalAsync(QueryType.SelectUnique(), testCol, prop, timeframe, interval)).ToList();

            if (null != queryMock)
                queryMock.VerifyAll();
        }
コード例 #2
0
ファイル: QueryTest.cs プロジェクト: kidchenko/keen-sdk-net
        public async void Query_ValidRelativeInterval_Success()
        {
            var client = new KeenClient(settingsEnv);
            var interval = QueryInterval.EveryNMinutes(5);
            var timeframe = QueryRelativeTimeframe.ThisMinute();
            IEnumerable<QueryIntervalValue<string>> result =
                new List<QueryIntervalValue<string>>() { new QueryIntervalValue<string>("0", DateTime.Now.AddMinutes(-5), DateTime.Now) };

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                queryMock = new Mock<IQueries>();
                queryMock.Setup(m => m.Metric(
                        It.Is<QueryType>(q => q == QueryType.Count()),
                        It.Is<string>(c => c == testCol),
                        It.Is<string>(p => p == ""),
                        It.Is<QueryTimeframe>(t => t == timeframe),
                        It.Is<QueryInterval>(i => i == interval),
                        It.Is<IEnumerable<QueryFilter>>(f => f == null),
                        It.Is<string>(z => z == "")))
                    .Returns(Task.FromResult(result));

                client.Queries = queryMock.Object;
            }

            var counts = (await client.QueryIntervalAsync(QueryType.Count(), testCol, "", timeframe, interval)).ToList();
            Assert.IsNotNull(counts);

            if (null != queryMock)
                queryMock.VerifyAll();
        }