<commit_before>from manager import cgs, tally
from tools import rreplace
import authorized

question_bank = {
	'total': 'How many youths came today, total?',
	'l': 'How many servers including yourself?',
	'f':'How many (F)reshies?',
	'nb':'How many (N)ew (B)elievers?',
	'nc':'How many (N)ew (C)omers?',
	'v':'How many (V)isitors?',
	'ir': 'How many (IR)regulars?',
}

question_order = ['total', 'l', 'f', 'ir', 'nb', 'nc', 'v',]

question_limit = len(question_order)

# produces a string for individual cg records, format:
# East (TJ): 30+3 (5F, 1NC, 2NB, 6IR)
def getCGFinalString(cg):
    cluster = authorized.getCluster(cg.lower())
    clusterFS = authorized.getClusterFriendlyString(cluster)
    cgDoc = cgs.find_one( { 'name': cg.lower() } )
    if cgDoc == None:
        return '%s (%s):' % (clusterFS.title(), cg.upper())
    return getFinalString(cgDoc, cg)

def getFinalString(cgDoc, cg=None, clusterFS=None):
    total = leaders = string = ''
    if cgDoc != None:
        clusterFS = authorized.getClusterFriendlyString(cgDoc.get('cluster', 'Error'))
        total = str(cgDoc.get('total', ''))
        leaders = str(cgDoc.get('l', ''))
        freshies = str(cgDoc.get('f', ''))
        ncs = str(cgDoc.get('nc', ''))
        nbs = str(cgDoc.get('nb', ''))
        irs = str(cgDoc.get('ir', ''))
        visitors = str(cgDoc.get('v', ''))
        # Add suffixes only if count is non-zero
        freshies = '' if freshies in ('','0') else freshies+'F, '
        ncs = '' if ncs in ('','0') else ncs+'NC, '
        nbs = '' if nbs in ('','0') else nbs+'NB, '
        irs = '' if irs in ('','0') else irs+'IR, '
        visitors = '' if visitors in ('','0') else visitors+'V, '
        string = freshies + irs + ncs + visitors + nbs
        # Rid last comma
        string = rreplace(string, ', ', '', 1)
    else:
        clusterFS = authorized.getClusterFriendlyString(clusterFS)
    if cg != None:<commit_msg>Fixes for cluster friendly string naming error.<commit_after>from manager import cgs, tally
from tools import rreplace
import authorized

question_bank = {
	'total': 'How many youths came today, total?',
	'l': 'How many servers including yourself?',
	'f':'How many (F)reshies?',
	'nb':'How many (N)ew (B)elievers?',
	'nc':'How many (N)ew (C)omers?',
	'v':'How many (V)isitors?',
	'ir': 'How many (IR)regulars?',
}

question_order = ['total', 'l', 'f', 'ir', 'nb', 'nc', 'v',]

question_limit = len(question_order)

# produces a string for individual cg records, format:
# East (TJ): 30+3 (5F, 1NC, 2NB, 6IR)
def getCGFinalString(cg):
    cluster = authorized.getCluster(cg.lower())
    clusterFS = authorized.getClusterFriendlyString(cluster)
    cgDoc = cgs.find_one( { 'name': cg.lower() } )
    if cgDoc == None:
        return '%s (%s):' % (clusterFS.title(), cg.upper())
    return getFinalString(cgDoc, cg)

def getFinalString(cgDoc, cg=None, clusterFS=None):
    total = leaders = string = ''
    # Blank cursors imply the CG has yet to submit attendance, so we skip them to show blank tally
    if cgDoc != None:
        total = str(cgDoc.get('total', ''))
        leaders = str(cgDoc.get('l', ''))
        freshies = str(cgDoc.get('f', ''))
        ncs = str(cgDoc.get('nc', ''))
        nbs = str(cgDoc.get('nb', ''))
        irs = str(cgDoc.get('ir', ''))
        visitors = str(cgDoc.get('v', ''))
        # Add suffixes only if count is non-zero
        freshies = '' if freshies in ('','0') else freshies+'F, '
        ncs = '' if ncs in ('','0') else ncs+'NC, '
        nbs = '' if nbs in ('','0') else nbs+'NB, '
        irs = '' if irs in ('','0') else irs+'IR, '
        visitors = '' if visitors in ('','0') else visitors+'V, '
        string = freshies + irs + ncs + visitors + nbs
        # Rid last comma
        string = rreplace(string, ', ', '', 1)
    # Blank clusterFS means the CG is querying this method for its tally string.
    if clusterFS == None:
        clusterFS = authorized.getClusterFriendlyString(cgDoc.get('cluster', 'Error'))
    else:
        clusterFS = authorized.getClusterFriendlyString(clusterFS)
    # Empty CGs mean that the cluster is looking for its total attendance.
    if cg != None:
{'fraction_non_alphanumeric': 0.17591925018024512, 'fraction_numerical': 0.006248497957221821, 'mean_word_length': 3.2125506072874495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1491103', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1428, 'n_words': 403}