Exemple #1
0
def save_metrics(content, user_id, actual_time):
    # I think you will be calling this interanall
    calculated = calculate_time(content, user_id)
    metrics = ReadSpeed.text_analytics(content)
    names = ['lexicon','sent','syll','flesch','smog','fog','dale','ari','cl',
             'flesch1','flesch2','flesch3',
             'smog1','smog2','smog3',
             'fog1','fog2','fog3',
             'dale1','dale2','dale3',
             'ari1','ari2','ari3',
             'cl1','cl2','cl3']
    to_save = {}
    for metric,name in zip(metrics,names):
        to_save[name]=metric

    # Save anything else you want here this is what you will be getting 
    to_save['calculated'] = calculated
    to_save['actual'] = actual_time
    db.add_info(user_id, to_save)
    return "done"