<commit_before><?php
use DBA\TwoCompareAnswer;

/**
 * Created by IntelliJ IDEA.
 * User: sein
 * Date: 18.04.17
 * Time: 16:57
 */
class PruneHandler extends Handler {
  
  /**
   * @param $action string action type which should be handled
   */
  public function handle($answer) {
    global $FACTORIES;
    
    $answeredTuple = $FACTORIES::getResultTupleFactory()->get($_POST['resultTupleId']);
    if ($answeredTuple == null) {
      UI::addErrorMessage("Invalid submission!");
      return;
    }
    else if ($answer == AnswerType::COMPARE_TWO_SKIP) {
      // no action required
      $_SESSION['lastId'] = $answeredTuple->getId();
    }
    else{
      $pruneSession = $FACTORIES::getAnswerSessionFactory()->get($_SESSION['pruneSessionId']);
      $twoCompareAnswer = new TwoCompareAnswer(0, time(), $answeredTuple->getId(), $answer, $pruneSession->getId());
      $FACTORIES::getTwoCompareAnswerFactory()->save($twoCompareAnswer);
      $_SESSION['lastId'] = $answeredTuple->getId();
    }<commit_msg>added saving of prune answer<commit_after><?php
use DBA\TwoCompareAnswer;

/**
 * Created by IntelliJ IDEA.
 * User: sein
 * Date: 18.04.17
 * Time: 16:57
 */
class PruneHandler extends Handler {
  
  /**
   * @param $action string action type which should be handled
   */
  public function handle($answer) {
    global $FACTORIES;
    
    $answeredTuple = $FACTORIES::getResultTupleFactory()->get($_POST['resultTupleId']);
    if ($answeredTuple == null) {
      UI::addErrorMessage("Invalid submission!");
      return;
    }
    else if ($answer == AnswerType::COMPARE_TWO_SKIP) {
      // no action required
      $_SESSION['lastId'] = $answeredTuple->getId();
    }
    else{
      $pruneSession = $FACTORIES::getAnswerSessionFactory()->get($_SESSION['pruneSessionId']);
      $twoCompareAnswer = new TwoCompareAnswer(0, time(), $answeredTuple->getId(), $answer, $pruneSession->getId());
      $FACTORIES::getTwoCompareAnswerFactory()->save($twoCompareAnswer);
      $answeredTuple->setIsFinal(1);
      $answeredTuple->setMu($answer);
      $answeredTuple->setSigma(0);
      $FACTORIES::getResultTupleFactory()->update($answeredTuple);
      $_SESSION['lastId'] = $answeredTuple->getId();
    }
{'fraction_non_alphanumeric': 0.15627822944896116, 'fraction_numerical': 0.01084010840108401, 'mean_word_length': 3.9552572706935125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6326473', 'n_tokens_mistral': 711, 'n_tokens_neox': 661, 'n_words': 130}