Get recent matches by clan.
169596
def get_clan_matches(session, subdomain, clan_id, from_timestamp=None, limit=None):
    """"""
    return get_recent_matches(session, 'https://{}.voobly.com/{}/{}/0'.format(
        subdomain, TEAM_MATCHES_URL, clan_id), from_timestamp, limit)
1213267
def filter_teams(self, teams):
		""""""
		return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams]
1062376
def recentMatches(self, **criteria):
        """"""
        if not self.matches: return [] # no match history
        try: # maxMatches is a specially handled parameter (not true criteria)
            maxMatches = criteria["maxMatches"]
            del criteria["maxMatches"]
        except AttributeError:
            maxMatches = c.RECENT_MATCHES
        alLMatches = self.matchSubset(**criteria)
        matchTimes = [(m.endTime, m) for m in matches]
        selMatches = sorted(matchTimes)[:maxMatches] # slice off X most recet matches
        retMatches = [m for endTime,m in selMatches] # extract matches only
        return retMatches
504041
async def get_matches(self, force_update=False) -> list:
        
        if force_update or self.matches is None:
            res = await self.connection('GET',
                                        'tournaments/{}/matches'.format(self._id),
                                        include_attachments=1)
            self._refresh_matches_from_json(res)
        return self.matches or []
1021002
def list(self, request):
        """"""
        query = get_query_params(request).get("search", "")
        results = []
        base = self.model.get_base_class()
        doctypes = indexable_registry.families[base]
        for doctype, klass in doctypes.items():
            name = klass._meta.verbose_name.title()
            if query.lower() in name.lower():
                results.append(dict(
                    name=name,
                    doctype=doctype
                ))
                results.sort(key=lambda x: x["name"])
        return Response(dict(results=results))
700190
def ladderPlayerInfo(cfg, playerName, getMatchHistory=False):
    """"""
    payload = json.dumps([playerName, getMatchHistory]) # if playerName == None, info on all players is retrieved
    ladder = cfg.ladder
    return requests.post(
        url  = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "playerstats"),
        data = payload,
        #headers=headers,
    )
1174927
def queries(self, last_updated_ms):
        """"""
        stats_logger.incr('queries')
        if not g.user.get_id():
            return json_error_response(
                'Please login to access the queries.', status=403)

        # Unix time, milliseconds.
        last_updated_ms_int = int(float(last_updated_ms)) if last_updated_ms else 0

        # UTC date time, same that is stored in the DB.
        last_updated_dt = utils.EPOCH + timedelta(seconds=last_updated_ms_int / 1000)

        sql_queries = (
            db.session.query(Query)
            .filter(
                Query.user_id == g.user.get_id(),
                Query.changed_on >= last_updated_dt,
            )
            .all()
        )
        dict_queries = {q.client_id: q.to_dict() for q in sql_queries}

        now = int(round(time.time() * 1000))

        unfinished_states = [
            QueryStatus.PENDING,
            QueryStatus.RUNNING,
        ]

        queries_to_timeout = [
            client_id for client_id, query_dict in dict_queries.items()
            if (
                query_dict['state'] in unfinished_states and (
                    now - query_dict['startDttm'] >
                    config.get('SQLLAB_ASYNC_TIME_LIMIT_SEC') * 1000
                )
            )
        ]

        if queries_to_timeout:
            update(Query).where(
                and_(
                    Query.user_id == g.user.get_id(),
                    Query.client_id in queries_to_timeout,
                ),
            ).values(state=QueryStatus.TIMED_OUT)

            for client_id in queries_to_timeout:
                dict_queries[client_id]['status'] = QueryStatus.TIMED_OUT

        return json_success(
            json.dumps(dict_queries, default=utils.json_int_dttm_ser))
83153
def reportMatchCompletion(cfg, results, replayData):
    """"""
    payload = json.dumps([cfg.flatten(), results, replayData])
    ladder = cfg.ladder
    return requests.post(
        url  = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "matchfinished"),
        data = payload,
        #headers=headers,
    )
54009
async def get_top_clans(self):
        ''''''
        url = self.BASE + '/top/clans'

        data = await self.request(url)

        return [ClanInfo(self, c) for c in data.get('clans')]
547559
function Clan(config) {

    //Read the clans data from a csv to an array object
    var readClan = function(data) {
        var members = [],
            space = new RegExp(String.fromCharCode(65533), 'g');

        for (var i = 1; i < data.length; i++) {
            var member = data[i];
            members.push({
                player: member[0].replace(space, ' '),
                rank: member[1],
                exp: Number(member[2]),
                kills: Number(member[3])
            });
        }

        return members;
    };

    /**
     * Get a clans member list with exp gained and total kills (available for `rs`)
     * @param  name The clans name
     * @returns {Object} Member list
     * @example
     * api.rs.hiscores.clan('Efficiency Experts').then(function(clan) {
     *   console.log(clan);
     * }).catch(console.error);
     */
    this.members = function(name) {
        return new Promise(function(resolve, reject) {
            if (typeof config.urls.members === 'undefined') {
                reject(new Error('Oldschool RuneScape does not have clans.'));
                return;
            }

            request.csv(config.urls.members + encodeURIComponent(name)).then(function(data) {
                resolve(readClan(data));
            }).catch(reject);
        });
    };
}
166984
def filterMapAttrs(records=getIndex(), **tags):
    """"""
    if len(tags) == 0: return records # otherwise if unspecified, all given records match
    ret = []
    for record in records: # attempt to match attributes
        if matchRecordAttrs(record, tags):
            ret.append(record)
    return ret
219463
def get_match_history_by_sequence_num(start_at_match_seq_num,
                                      matches_requested=None, **kwargs):
    
    params = {
        "start_at_match_seq_num": start_at_match_seq_num,
        "matches_requested": matches_requested
    }

    return make_request("GetMatchHistoryBySequenceNum", params,
        **kwargs)
555724
def recent_messages(limit = nil, &callback)
      connection.http(:get, "/room/#{id}/recent.json", (limit ? { :limit => limit } : nil)) do |data, http|
        callback.call(data[:messages].map { |msg| Firering::Message.instantiate(connection, msg) }) if callback
      end
    end
338811
def get_match_history(start_at_match_id=None, player_name=None, hero_id=None,
                      skill=0, date_min=None, date_max=None, account_id=None,
                      league_id=None, matches_requested=None, game_mode=None,
                      min_players=None, tournament_games_only=None,
                      **kwargs):
    

    params = {
        "start_at_match_id": start_at_match_id,
        "player_name": player_name,
        "hero_id": hero_id,
        "skill": skill,
        "date_min": date_min,
        "date_max": date_max,
        "account_id": account_id,
        "league_id": league_id,
        "matches_requested": matches_requested,
        "game_mode": game_mode,
        "min_players": min_players,
        "tournament_games_only": tournament_games_only
    }

    return make_request("GetMatchHistory", params, **kwargs)
1044792
def get_context_data(self, **kwargs):
        """"""
        r = get_r()
        data = super(AggregateHistoryView, self).get_context_data(**kwargs)
        slug_set = set(kwargs['slugs'].split('+'))
        granularity = kwargs.get('granularity', 'daily')

        # Accept GET query params for ``since``
        since = self.request.GET.get('since', None)
        if since and len(since) == 10:  # yyyy-mm-dd
            since = datetime.strptime(since, "%Y-%m-%d")
        elif since and len(since) == 19:  # yyyy-mm-dd HH:MM:ss
            since = datetime.strptime(since, "%Y-%m-%d %H:%M:%S")

        data.update({
            'slugs': slug_set,
            'granularity': granularity,
            'since': since,
            'granularities': list(r._granularities())
        })
        return data
64015
def filter(self, table, groups, filter_string):
        """"""
        query = filter_string.lower()
        return [group for group in groups
                if query in group.name.lower()]
171959
def get_result_group_names(self, request_datetime):
        """"""
        request_date = request_datetime.date()
        today = datetime.date.today()
        yesterday = datetime.date.today() - datetime.timedelta(days=1)
        result = []
        if total_seconds(datetime.datetime.now() - request_datetime) < REALTIME_UPDATE_INTERVAL:
            result.append('last_interval')
        if request_date == today:
            result.append(today.isoformat())
        elif request_date == yesterday:
            result.append(yesterday.isoformat())
        return result