<commit_before>var _ = require('lodash')
var moment = require('moment')


/**
 * @class HistoryEntryModel
 *
 * @param {historyEntry} HistoryEntry
 */
function HistoryEntryModel(historyEntry) {
  this.historyEntry = historyEntry
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getTxId = function() {
  return this.historyEntry.txId
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getDate = function() {
  var timezoneOffset = new Date().getTimezoneOffset() * 60
  var date = this.historyEntry.getTimestamp() - timezoneOffset
  return moment(date*1000).format('MM/DD/YY HH:mm:ss')
}

/**
 * @return {string[]}
 */
HistoryEntryModel.prototype.getValues = function() {
  var values = this.historyEntry.getValues().map(function(av) {
    return av.getAsset().formatValue(av.getValue())
  })

  return values
}

/**
 * @typedef {Object} HistoryTarget
 * @property {string} address0
 * @property {string} address1
 * @property {string} addressN
 */

/**
 * @return {HistoryTarget}
 */
HistoryEntryModel.prototype.getTargets = function() {
  var targets = this.historyEntry.getTargets().map(function(at) {
    return [at.getAddress(), at.getAsset().formatValue(at.getValue())]
  })

  return _.object(targets)
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isSend = function() {
  return this.historyEntry.isSend()
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isReceive = function() {
  return this.historyEntry.isReceive()
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isPaymentToYourself = function() {
  return this.historyEntry.isPaymentToYourself()
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getTransactionType = function() {
  if (this.isSend())
    return 'Send'

  if (this.isReceive())
    return 'Receive'

  if (this.isPaymentToYourself())
    return 'Payment to yourself'
}<commit_msg>history API to use AssetTargetModel<commit_after>var _ = require('lodash')
var moment = require('moment')


function AssetTargetModel(assetTarget) {
    this.address = assetTarget.getAddress();
    var value = assetTarget.getValue(),
        asset = assetTarget.getAsset();
    this.formattedValue = asset.formatValue(value);
    this.assetMoniker = asset.getMonikers()[0];
}

AssetTargetModel.prototype.getAddress = function () {
    return this.address;
};
AssetTargetModel.prototype.getAssetMoniker = function () {
    return this.assetMoniker;
};
AssetTargetModel.prototype.getFormattedValue = function () {
    return this.formattedValue;
};



/**
 * @class HistoryEntryModel
 *
 * @param {historyEntry} HistoryEntry
 */
function HistoryEntryModel(historyEntry) {
  this.historyEntry = historyEntry
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getTxId = function() {
  return this.historyEntry.txId
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getDate = function() {
  var timezoneOffset = new Date().getTimezoneOffset() * 60
  var date = this.historyEntry.getTimestamp() - timezoneOffset
  return moment(date*1000).format('MM/DD/YY HH:mm:ss')
}

/**
 * @return {string[]}
 */
HistoryEntryModel.prototype.getValues = function() {
  var values = this.historyEntry.getValues().map(function(av) {
    return av.getAsset().formatValue(av.getValue())
  })

  return values
}

/**
 * @return {AssetTargetModel[]}
 */
HistoryEntryModel.prototype.getTargets = function() {
    return this.historyEntry.getTargets().map(function(at) {
        return new AssetTargetModel(at);
    });
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isSend = function() {
  return this.historyEntry.isSend()
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isTrade = function() {
    return false; // TODO
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isReceive = function() {
  return this.historyEntry.isReceive()
}

/**
 * @return {boolean}
 */
HistoryEntryModel.prototype.isPaymentToYourself = function() {
  return this.historyEntry.isPaymentToYourself()
}

/**
 * @return {string}
 */
HistoryEntryModel.prototype.getTransactionType = function() {
  if (this.isSend())
    return 'Send'

  if (this.isReceive())
    return 'Receive'

  if (this.isPaymentToYourself())
    return 'Payment to yourself'
}
{'fraction_non_alphanumeric': 0.15043828476664298, 'fraction_numerical': 0.0035536602700781805, 'mean_word_length': 4.337547408343869, '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': '5867195', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1294, 'n_words': 235}