<commit_before>import rootRef from '../libs/firebase';
import _ from 'lodash';

import { SessionApi } from '../libs/sessions_api';

const C = require('../constants').default;

const sessionsRef = rootRef.child('savedSessions');

export default {
  get(sessionID, callback) {
    SessionApi.get(sessionID).then((session) => {
      const processedSession = processSession(session)
      callback(processed_session)
    }).catch((error) => {
      sessionsRef.child(sessionID).once('value', (snapshot) => {
        if (snapshot.exists()) {
          const session = snapshot.val();
          const processed_session = processSession(session)
          callback(processed_session);
        }
      })
    })
  },

  update(sessionID, session) {
    const cleanSession = _.pickBy(session);
    const cleanedSession = JSON.parse(JSON.stringify(cleanSession));
    delete_null_properties(cleanedSession, true);
    SessionApi.update(sessionID, cleanedSession);
  },

  delete(sessionID) {
    sessionsRef.child(sessionID).remove();
  },

};

function processSession(session) {
  if (session.currentQuestion) {
    if (session.currentQuestion.question) {
      session.currentQuestion.question.attempts = [];
    } else {
      session.currentQuestion.data.attempts = [];
    }
  }
  session.unansweredQuestions = session.unansweredQuestions || [];
  return session
}
<commit_msg>Commit file with updated variable names (#6545)<commit_after>import rootRef from '../libs/firebase';
import _ from 'lodash';

import { SessionApi } from '../libs/sessions_api';

const C = require('../constants').default;

const sessionsRef = rootRef.child('savedSessions');

export default {
  get(sessionID, callback) {
    SessionApi.get(sessionID).then((session) => {
      const processedSession = processSession(session)
      callback(processedSession)
    }).catch((error) => {
      sessionsRef.child(sessionID).once('value', (snapshot) => {
        if (snapshot.exists()) {
          const session = snapshot.val();
          const processedSession = processSession(session)
          callback(processedSession);
        }
      })
    })
  },

  update(sessionID, session) {
    const cleanSession = _.pickBy(session);
    const cleanedSession = JSON.parse(JSON.stringify(cleanSession));
    delete_null_properties(cleanedSession, true);
    SessionApi.update(sessionID, cleanedSession);
  },

  delete(sessionID) {
    sessionsRef.child(sessionID).remove();
  },

};

function processSession(session) {
  if (session.currentQuestion) {
    if (session.currentQuestion.question) {
      session.currentQuestion.question.attempts = [];
    } else {
      session.currentQuestion.data.attempts = [];
    }
  }
  session.unansweredQuestions = session.unansweredQuestions || [];
  return session
}

{'fraction_non_alphanumeric': 0.13503781058696435, 'fraction_numerical': 0.0014404033129276198, 'mean_word_length': 3.5917355371900825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5209972', 'n_tokens_mistral': 804, 'n_tokens_neox': 780, 'n_words': 136}