<commit_before>module.exports = {
    /************************ Feedback Event *******************************************/
    getCountFeedbackItems: function( userId ){
        return {
            'name': "totalFeedbackCount",
            'data':[userId],
            'request': "select userId, COUNT(*) as value from feedback where userId = ?"
        };
    },

    getFeedbackPerTool: function( userId, toolName ){
        return {
            'name': "totalFeedbackPerTool",
            'data':[userId, toolName],
            'request': "select COUNT(*) as value from feedback where userId = ? and toolName = ?"
        };
    },

    getMostRecentFeedback: function(userId ){
        return { 
            'name': "mostRecentFeedback",
            'data':[userId],
            'request': "select * from feedback where userId = ? and submissionId = (select MAX(submissionId) from feedback) ORDER BY filename,lineNum,charPos,toolName"
        }
    },

    /* IGNORES visual feedback information */
    getMostRecentFeedbackNonVisual: function(userId ){
        return { 
            'name': "mostRecentFeedbackNonVisual",
            'data':[userId],
            'request': "select * from feedback where userId = ? and runType in (\"writing\",\"programming\") and submissionId = (select MAX(submissionId) from feedback) ORDER BY filename,lineNum,charPos,toolName"
        }
    },

    getMostRecentFeedbackPerTool: function(userId, toolName ){
         return { 
            'name': "mostRecentFeedbackPerTool",
            'data':[userId,toolName],
            'request': "select * from feedback where userId = ? and toolName = ? and submissionId = (select MAX(submissionId) from feedback where userId = ?) ORDER BY filename,lineNum,charPos, toolName"
        }
    },

    getCountFeedbackViews: function( userId ) {
        return {
            'name': "countFeedbackViews",
            'data':[userId, "view", "feedback"],
            'request':"select COUNT(*) as value from userInteractions where userId = ? eventType = ? and name = ?"
        };
    },

    getFeedbackCountPerTool: function( userId ) {
        return {
            'name': "toolsFeedbackCount",
            'data':[userId],
            'request':"select toolName, COUNT(*) from feedback where userId = ? GROUP BY toolName"
        };
    },

    getMeanFeedbackPerTool: function( userId ) {<commit_msg>Bug Fix: Feedback page used to selected most recent feedback which is incorrect. It needs to check submission numbers in case no feedback existed.<commit_after>module.exports = {
    /************************ Feedback Event *******************************************/
    getCountFeedbackItems: function( userId ){
        return {
            'name': "totalFeedbackCount",
            'data':[userId],
            'request': "select userId, COUNT(*) as value from feedback where userId = ?"
        };
    },

    getFeedbackPerTool: function( userId, toolName ){
        return {
            'name': "totalFeedbackPerTool",
            'data':[userId, toolName],
            'request': "select COUNT(*) as value from feedback where userId = ? and toolName = ?"
        };
    },

    getMostRecentFeedback: function(userId ){
        return { 
            'name': "mostRecentFeedback",
            'data':[userId,userId],
            'request': "select * from feedback where userId = ? and submissionId = (select id from submission where userId = ? ORDER By date DESC Limit 1) ORDER BY filename,lineNum,charPos,toolName"
        }
    },

    /* IGNORES visual feedback information */
    getMostRecentFeedbackNonVisual: function(userId ){
        return { 
            'name': "mostRecentFeedbackNonVisual",
            'data':[userId,userId],
            'request': "select * from feedback where userId = ? and runType in (\"writing\",\"programming\") and submissionId = (select id from submission where userId = ? ORDER By date DESC Limit 1) ORDER BY filename,lineNum,charPos,toolName"
        }
    },

    getMostRecentFeedbackPerTool: function(userId, toolName ){
         return { 
            'name': "mostRecentFeedbackPerTool",
            'data':[userId,toolName,userId],
            'request': "select * from feedback where userId = ? and toolName = ? and submissionId = (select id from submission where userId = ? ORDER By date DESC Limit 1) ORDER BY filename,lineNum,charPos, toolName"
        }
    },

    getCountFeedbackViews: function( userId ) {
        return {
            'name': "countFeedbackViews",
            'data':[userId, "view", "feedback"],
            'request':"select COUNT(*) as value from userInteractions where userId = ? eventType = ? and name = ?"
        };
    },

    getFeedbackCountPerTool: function( userId ) {
        return {
            'name': "toolsFeedbackCount",
            'data':[userId],
            'request':"select toolName, COUNT(*) from feedback where userId = ? GROUP BY toolName"
        };
    },

    getMeanFeedbackPerTool: function( userId ) {
{'fraction_non_alphanumeric': 0.14, 'fraction_numerical': 0.0006, 'mean_word_length': 2.5619658119658117, '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': '4328740', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1317, 'n_words': 359}