parameters: (sheriff_key, include_improvements, include_triaged)
return_statement: return query.fetch(limit=_MAX_ANOMALIES_TO_COUNT, keys_only=True)
docstring: Fetches the list of Anomaly keys that may be shown.
  
    Args:
      sheriff_key: The ndb.Key for the Sheriff to fetch alerts for.
      include_improvements: Whether to include improvement Anomalies.
      include_triaged: Whether to include Anomalies with a bug ID already set.
  
    Returns:
      A list of Anomaly keys, in reverse-chronological order.
docstring_summary: Fetches the list of Anomaly keys that may be shown.
docstring_tokens: Fetches the list of Anomaly keys that may be shown .
function: def _FetchAnomalyKeys(sheriff_key, include_improvements, include_triaged):
    """Fetches the list of Anomaly keys that may be shown.
  
    Args:
      sheriff_key: The ndb.Key for the Sheriff to fetch alerts for.
      include_improvements: Whether to include improvement Anomalies.
      include_triaged: Whether to include Anomalies with a bug ID already set.
  
    Returns:
      A list of Anomaly keys, in reverse-chronological order.
    """
    query = anomaly.Anomaly.query(
        anomaly.Anomaly.sheriff == sheriff_key)
  
    if not include_improvements:
      query = query.filter(
          anomaly.Anomaly.is_improvement == False)
  
    if not include_triaged:
      query = query.filter(
          anomaly.Anomaly.bug_id == None)
      query = query.filter(
          anomaly.Anomaly.recovered == False)
  
    query = query.order(-anomaly.Anomaly.timestamp)
    return query.fetch(limit=_MAX_ANOMALIES_TO_COUNT, keys_only=True)
function_tokens: def _FetchAnomalyKeys ( sheriff_key , include_improvements , include_triaged ) : query = anomaly . Anomaly . query ( anomaly . Anomaly . sheriff == sheriff_key ) if not include_improvements : query = query . filter ( anomaly . Anomaly . is_improvement == False ) if not include_triaged : query = query . filter ( anomaly . Anomaly . bug_id == None ) query = query . filter ( anomaly . Anomaly . recovered == False ) query = query . order ( - anomaly . Anomaly . timestamp ) return query . fetch ( limit = _MAX_ANOMALIES_TO_COUNT , keys_only = True )