コード例 #1
0
        public IAsyncEnumerable <RosterUpdateView> GetRosterUpdates(RosterUpdateQueryOpts opts)
        {
            var q = new SqlKata.Query("roster_versions")
                    .ApplySorting(opts, "first_seen", "update_id")
                    .ApplyBounds(opts, "first_seen");

            if (opts.Teams != null)
            {
                q.WhereIn("team_id", opts.Teams);
            }
            if (opts.Players != null)
            {
                q.WhereIn("player_id", opts.Players);
            }

            return(_db.QueryKataAsync <RosterUpdateView>(q));
        }
コード例 #2
0
        private IAsyncEnumerable <TributesUpdateView> GetTributeUpdatesInner(string table, TributesQuery opts)
        {
            var q = new SqlKata.Query(table)
                    .SelectRaw("update_id, timestamp, array_agg(player_id) as players, array_agg(peanuts) as peanuts")
                    .GroupBy("timestamp", "update_id")
                    .ApplySorting(opts, "timestamp", "update_id")
                    .ApplyBounds(opts, "timestamp");

            if (opts.Players != null)
            {
                q.WhereIn("player_id", opts.Players);
            }

            return(_db.QueryKataAsync <TributesUpdateView>(q));
        }
コード例 #3
0
        public IAsyncEnumerable <GameUpdateView> GetGameUpdates(GameUpdateQueryOptions opts, bool ignoreSort = false)
        {
            var q = new SqlKata.Query("game_updates_unique")
                    .Select("game_id", "timestamp", "hash", "data")
                    .ApplyBounds(opts, "timestamp");

            if (!ignoreSort)
            {
                q.ApplySorting(opts, "timestamp", "hash");
            }

            if (opts.Season != null)
            {
                q.Where("season", opts.Season.Value);
            }
            if (opts.Tournament != null)
            {
                q.Where("tournament", opts.Tournament.Value);
            }
            if (opts.Day != null)
            {
                q.Where("day", opts.Day.Value);
            }
            if (opts.Game != null)
            {
                q.WhereIn("game_id", opts.Game);
            }
            if (opts.Search != null)
            {
                q.WhereRaw("search_tsv @@ websearch_to_tsquery(?)", opts.Search);
            }
            if (opts.Started != null)
            {
                q.WhereRaw("(data->>'gameStart')::bool = ?", opts.Started.Value);
            }

            return(_db.QueryKataAsync <GameUpdateView>(q));
        }