

def _get_old_unhelpful():
    '\n    Gets the data from 2 weeks ago and formats it as output so that we can\n    get a percent change.\n    '
    old_formatted = {
        
    }
    cursor = connection.cursor()
    cursor.execute('SELECT doc_id, yes, no\n        FROM\n            (SELECT wiki_revision.document_id as doc_id,\n                SUM(limitedvotes.helpful) as yes,\n                SUM(NOT(limitedvotes.helpful)) as no\n            FROM\n                (SELECT * FROM wiki_helpfulvote\n                    WHERE created <= DATE_SUB(CURDATE(), INTERVAL 1 WEEK)\n                    AND created >= DATE_SUB(DATE_SUB(CURDATE(),\n                        INTERVAL 1 WEEK), INTERVAL 1 WEEK)\n                ) as limitedvotes\n            INNER JOIN wiki_revision ON\n                limitedvotes.revision_id=wiki_revision.id\n            INNER JOIN wiki_document ON\n                wiki_document.id=wiki_revision.document_id\n            WHERE wiki_document.locale="en-US"\n            GROUP BY doc_id\n            HAVING no > yes\n            ) as calculated')
    old_data = cursor.fetchall()
    for data in old_data:
        doc_id = data[0]
        yes = float(data[1])
        no = float(data[2])
        total = (yes + no)
        if (total == 0):
            continue
        old_formatted[doc_id] = {
            'total': total,
            'percentage': (yes / total),
        }
    return old_formatted

dataset/ETHPy150Open mozilla/kitsune/kitsune/dashboards/cron.py _get_old_unhelpful/original