def _BuildSnapshotQuery(self, cols, where, joins, group_by, shard_id):
    'Given SQL arguments, executes a snapshot COUNT query.'
    stmt = sql.Statement.MakeSelect('IssueSnapshot', cols, distinct=True)
    stmt.AddJoinClauses(joins, left=True)
    stmt.AddWhereTerms((where + [('IssueSnapshot.shard = %s', [shard_id])]))
    if group_by:
        stmt.AddGroupByTerms(group_by)
    stmt.SetLimitAndOffset(limit=settings.chart_query_max_rows, offset=0)
    (stmt_str, stmt_args) = stmt.Generate()
    if group_by:
        if (group_by[0] == 'IssueSnapshot.is_open'):
            count_stmt = ('SELECT IF(results.is_open = 1, "Opened", "Closed") AS bool_open, results.issue_count FROM (%s) AS results' % stmt_str)
        else:
            count_stmt = stmt_str
    else:
        count_stmt = ('SELECT COUNT(results.issue_id) FROM (%s) AS results' % stmt_str)
    return (count_stmt, stmt_args)
Given SQL arguments, executes a snapshot COUNT query.
def _BuildSnapshotQuery(self, cols, where, joins, group_by, shard_id):
    
    stmt = sql.Statement.MakeSelect('IssueSnapshot', cols, distinct=True)
    stmt.AddJoinClauses(joins, left=True)
    stmt.AddWhereTerms((where + [('IssueSnapshot.shard = %s', [shard_id])]))
    if group_by:
        stmt.AddGroupByTerms(group_by)
    stmt.SetLimitAndOffset(limit=settings.chart_query_max_rows, offset=0)
    (stmt_str, stmt_args) = stmt.Generate()
    if group_by:
        if (group_by[0] == 'IssueSnapshot.is_open'):
            count_stmt = ('SELECT IF(results.is_open = 1, "Opened", "Closed") AS bool_open, results.issue_count FROM (%s) AS results' % stmt_str)
        else:
            count_stmt = stmt_str
    else:
        count_stmt = ('SELECT COUNT(results.issue_id) FROM (%s) AS results' % stmt_str)
    return (count_stmt, stmt_args)