<commit_before>var util = require('util'),
    Tab = require('../client/tab').Tab,
    rewriter = require('../util/jsonrewriter');

var HistoryTab = function ()
{
  Tab.call(this);
};

util.inherits(HistoryTab, Tab);

HistoryTab.prototype.tabName = 'history';
HistoryTab.prototype.mainMenu = 'wallet';

HistoryTab.prototype.generateHtml = function ()
{
  return require('../../jade/tabs/history.jade')();
};

HistoryTab.prototype.angular = function (module) {
  module.controller('HistoryCtrl', ['$scope', 'rpId', 'rpNetwork', 'rpTracker', 'rpAppManager',
                                     function ($scope, $id, $network, $rpTracker, appManager)
  {
    if (!$id.loginStatus) return $id.goId();

    var history = [];

    // Latest transaction
    var latest;

    // History collection
    $scope.historyShow = [];

    // History states
    $scope.$watch('loadState.transactions',function(){
      $scope.historyState = !$scope.loadState.transactions ? 'loading' : 'ready';
    });

    // Open/close states of individual history items
    $scope.details = [];

    //$scope.typeUsage = [];
    //$scope.currencyUsage = [];

    // Currencies from history
    var historyCurrencies = [];

    $scope.types = {
      sent: {
        'types': ['sent'],
        'checked': true
      },
      received: {
        'types': ['received'],
        'checked': true
      },
      trusts: {
        'types': ['trusting','trusted'],
        'checked': true
      },
      offers: {
        'types': ['offernew','offercancel','exchange'],
        'checked': true
      },
      other: {
        'types': ['accountset','failed','rippling'],
        'checked': true
      }
    };

    $scope.orderedTypes = ['sent','received','trusts','offers','other'];

    if (store.get('ripple_history_type_selections')) {
      $scope.types = $.extend(true,$scope.types,store.get('ripple_history_type_selections'));
    }

    // Filters
    if (store.get('ripple_history_filters')) {
      $scope.filters = store.get('ripple_history_filters');
    } else {
      $scope.filters = {
        'currencies_is_active': false, // we do the currency filter only if this is true, which happens when at least one currency is off
        'currencies': {},
        'types': ['sent','received','exchange','trusting','trusted','offernew','offercancel','rippling'],
        'minimumAmount': 0.000001
      };
    }

    var getDateRangeHistory = function(dateMin,dateMax,callback)
    {
      var completed = false;
      var history = [];

      var params = {
        'account': $id.account,
        'ledger_index_min': -1,
        'limit': 200
      };

      var getTx = function(){
        $network.remote.request_account_tx(params)
        .on('success', function(data) {
          if (data.transactions.length) {
            for(var i=0;i<data.transactions.length;i++) {
              var date = ripple.utils.toTimestamp(data.transactions[i].tx.date);

              if(date < dateMin.getTime()) {
                completed = true;
                break;
              }

              if(date > dateMax.getTime())
                continue;

              // Push
              var tx = rewriter.processTxn(data.transactions[i].tx, data.transactions[i].meta, $id.account);
              if (tx) history.push(tx);
            }

            params.marker = data.marker;
            $scope.tx_marker = params.marker;

            if (completed)
              callback(history);
            else
              getTx();
          } else {
            callback(history);
          }
        }).request();
      };

      getTx(0);
    };

    // DateRange filter form
    $scope.submitDateRangeForm = function() {
      $scope.dateMaxView.setDate($scope.dateMaxView.getDate() + 1); // Including last date
      changeDateRange($scope.dateMinView,$scope.dateMaxView);
    };

    $scope.submitMinimumAmountForm = function() {
      updateHistory();
    };

    var changeDateRange = function(dateMin,dateMax) {
      history = [];
      $scope.historyState = 'loading';

      getDateRangeHistory(dateMin,dateMax,function(hist){
        $scope.$apply(function () {
          history = hist;
          $scope.historyState = 'ready';
        })
      })
    };

    // All the currencies
    $scope.$watch('balances', function(){
      updateCurrencies();
    });
<commit_msg>[FIX] Fixed transaction date filter<commit_after>var util = require('util'),
    Tab = require('../client/tab').Tab,
    rewriter = require('../util/jsonrewriter');

var HistoryTab = function ()
{
  Tab.call(this);
};

util.inherits(HistoryTab, Tab);

HistoryTab.prototype.tabName = 'history';
HistoryTab.prototype.mainMenu = 'wallet';

HistoryTab.prototype.generateHtml = function ()
{
  return require('../../jade/tabs/history.jade')();
};

HistoryTab.prototype.angular = function (module) {
  module.controller('HistoryCtrl', ['$scope', 'rpId', 'rpNetwork', 'rpTracker', 'rpAppManager',
                                     function ($scope, $id, $network, $rpTracker, appManager)
  {
    if (!$id.loginStatus) return $id.goId();

    var history = [];

    // Latest transaction
    var latest;

    // History collection
    $scope.historyShow = [];

    // History states
    $scope.$watch('loadState.transactions',function(){
      $scope.historyState = !$scope.loadState.transactions ? 'loading' : 'ready';
    });

    // Open/close states of individual history items
    $scope.details = [];

    //$scope.typeUsage = [];
    //$scope.currencyUsage = [];

    // Currencies from history
    var historyCurrencies = [];

    $scope.types = {
      sent: {
        'types': ['sent'],
        'checked': true
      },
      received: {
        'types': ['received'],
        'checked': true
      },
      trusts: {
        'types': ['trusting','trusted'],
        'checked': true
      },
      offers: {
        'types': ['offernew','offercancel','exchange'],
        'checked': true
      },
      other: {
        'types': ['accountset','failed','rippling'],
        'checked': true
      }
    };

    $scope.orderedTypes = ['sent','received','trusts','offers','other'];

    if (store.get('ripple_history_type_selections')) {
      $scope.types = $.extend(true,$scope.types,store.get('ripple_history_type_selections'));
    }

    // Filters
    if (store.get('ripple_history_filters')) {
      $scope.filters = store.get('ripple_history_filters');
    } else {
      $scope.filters = {
        'currencies_is_active': false, // we do the currency filter only if this is true, which happens when at least one currency is off
        'currencies': {},
        'types': ['sent','received','exchange','trusting','trusted','offernew','offercancel','rippling'],
        'minimumAmount': 0.000001
      };
    }

    var getDateRangeHistory = function(dateMin,dateMax,callback)
    {
      var completed = false;
      var history = [];

      var params = {
        'account': $id.account,
        'ledger_index_min': -1,
        'limit': 200
      };

      var getTx = function(){
        $network.remote.request_account_tx(params)
        .on('success', function(data) {
          if (data.transactions.length) {
            for(var i=0;i<data.transactions.length;i++) {
              var date = ripple.utils.toTimestamp(data.transactions[i].tx.date);

              if(date < dateMin.getTime()) {
                completed = true;
                break;
              }

              if(date > dateMax.getTime())
                continue;

              // Push
              var tx = rewriter.processTxn(data.transactions[i].tx, data.transactions[i].meta, $id.account);
              if (tx) history.push(tx);
            }

            if (data.marker) {
              params.marker = data.marker;
              $scope.tx_marker = params.marker;
            }
            else {
              // Received all transactions since a marker was not returned
              completed = true;
            }

            if (completed)
              callback(history);
            else
              getTx();
          } else {
            callback(history);
          }
        }).request();
      };

      getTx(0);
    };

    // DateRange filter form
    $scope.submitDateRangeForm = function() {
      $scope.dateMaxView.setDate($scope.dateMaxView.getDate() + 1); // Including last date
      changeDateRange($scope.dateMinView,$scope.dateMaxView);
    };

    $scope.submitMinimumAmountForm = function() {
      updateHistory();
    };

    var changeDateRange = function(dateMin,dateMax) {
      history = [];
      $scope.historyState = 'loading';

      getDateRangeHistory(dateMin,dateMax,function(hist){
        $scope.$apply(function () {
          history = hist;
          $scope.historyState = 'ready';
          updateHistory();
        })
      })
    };

    // All the currencies
    $scope.$watch('balances', function(){
      updateCurrencies();
    });

{'fraction_non_alphanumeric': 0.15367383512544802, 'fraction_numerical': 0.0031362007168458782, 'mean_word_length': 2.15400918403391, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288115', 'n_tokens_mistral': 2649, 'n_tokens_neox': 2536, 'n_words': 471}