<commit_before>/**
 * Created by lilu on 2017/10/14.
 */

import {Map, List, Record} from 'immutable'
import {createAction} from 'redux-actions'
import {REHYDRATE} from 'redux-persist/constants'
import {call, put, takeEvery, takeLatest} from 'redux-saga/effects'
import { action as authAction, selector} from '../../util/auth'
import * as accountFunc from './cloud'
import {stationAction,stationSelector} from '../station/'
import {formatLeancloudTime} from '../../util/datetime'
/****  Model  ****/

export const AccountRecord = Record({
  stationAccountList: List(),
  stationAccountsDetailList: List(),
  allStationAccounts: Map(),
  allAccountProfits: Map(),
  partnerAccountList: List(),
  investorAccountList: List(),
  partnerAccountsDetailList: List(),
  investorAccountsDetailList: List(),
}, "StationRecord")

export const StationAccountRecord = Record({
  id: undefined,
  accountDay: undefined,
  profit: undefined,
  cost: undefined,
  platformProfit: undefined,
  incoming: undefined,
  partnerProfit: undefined,
  investorProfit: undefined,
  powerUnitPrice: undefined,
  stationId: undefined,
  createdAt: undefined,
}, 'StationAccountRecord')

export class StationAccount extends StationAccountRecord {
  static fromApi(obj) {
    // console.log('obj====>', obj)
    let stationDetail = new StationAccountRecord()
    return stationDetail.withMutations((record) => {
      record.set('id', obj.id)
      record.set('accountDay', formatLeancloudTime(new Date(obj.accountDay),'YYYY-MM-DD'))
      record.set('profit', obj.profit)
      record.set('platformProfit', obj.platformProfit)
      record.set('cost', obj.cost)
      record.set('partnerProfit', obj.partnerProfit)
      record.set('investorProfit', obj.investorProfit)
      record.set('incoming', obj.incoming)
      record.set('powerUnitPrice', obj.powerUnitPrice)
      record.set('stationId', obj.stationId)
      record.set('createdAt', obj.createdAt)
    })
  }
}

export const SharingAccountRecord = Record({
  id: undefined,
  accountDay: undefined,
  profit: undefined,
  stationId: undefined,
  userId: undefined,

}, 'SharingAccountRecord')

export class SharingAccount extends SharingAccountRecord {
  static fromApi(obj) {
    // console.log('obj====>', obj)
    let stationDetail = new SharingAccountRecord()
    return stationDetail.withMutations((record) => {
      record.set('id', obj.id)
      record.set('accountDay', formatLeancloudTime(new Date(obj.accountDay),'YYYY-MM-DD'))
      record.set('profit', obj.profit)
      record.set('stationId', obj.stationId)
      record.set('userId', obj.userId)
    })
  }
}

class AccountProfit extends Record({
  id: undefined,
  stationId: undefined,
  stationAccountId: undefined,
  profit: undefined,
  profitSharingId: undefined,
  accountDay: undefined,
  accountType: undefined,
  userId: undefined,
  createdAt: undefined,
  updatedAt: undefined,
}, 'AccountProfit') {
  static fromJson(json) {
    let profit = new AccountProfit()
    return profit.withMutations((record) => {
      record.set('id', json.id)
      record.set('stationId', json.stationId)
      record.set('stationAccountId', json.stationAccountId)
      record.set('profit', json.profit)
      record.set('profitSharingId', json.profitSharingId)
      record.set('accountDay', json.accountDay)
      record.set('accountType', json.accountType)
      record.set('userId', json.userId)
      record.set('createdAt', json.createdAt)
      record.set('updatedAt', json.updatedAt)
    })
  }
}

/**** Constant ****/<commit_msg>delete useless code and modify date convert<commit_after>/**
 * Created by lilu on 2017/10/14.
 */

import {Map, List, Record} from 'immutable'
import {createAction} from 'redux-actions'
import {REHYDRATE} from 'redux-persist/constants'
import {call, put, takeEvery, takeLatest} from 'redux-saga/effects'
import { action as authAction, selector} from '../../util/auth'
import * as accountFunc from './cloud'
import {stationAction,stationSelector} from '../station/'
import moment from 'moment'

/****  Model  ****/

export const AccountRecord = Record({
  stationAccountList: List(),
  stationAccountsDetailList: List(),
  allStationAccounts: Map(),
  allAccountProfits: Map(),
  partnerAccountList: List(),
  investorAccountList: List(),
  partnerAccountsDetailList: List(),
  investorAccountsDetailList: List(),
}, "StationRecord")

export const StationAccountRecord = Record({
  id: undefined,
  accountDay: undefined,
  profit: undefined,
  cost: undefined,
  platformProfit: undefined,
  incoming: undefined,
  partnerProfit: undefined,
  investorProfit: undefined,
  powerUnitPrice: undefined,
  stationId: undefined,
  createdAt: undefined,
}, 'StationAccountRecord')

export class StationAccount extends StationAccountRecord {
  static fromApi(obj) {
    // console.log('obj====>', obj)
    let stationDetail = new StationAccountRecord()
    return stationDetail.withMutations((record) => {
      record.set('id', obj.id)
      record.set('accountDay', moment(new Date(obj.accountDay)).format('YYYY-MM-DD'))
      record.set('profit', obj.profit)
      record.set('platformProfit', obj.platformProfit)
      record.set('cost', obj.cost)
      record.set('partnerProfit', obj.partnerProfit)
      record.set('investorProfit', obj.investorProfit)
      record.set('incoming', obj.incoming)
      record.set('powerUnitPrice', obj.powerUnitPrice)
      record.set('stationId', obj.stationId)
      record.set('createdAt', obj.createdAt)
    })
  }
}

class AccountProfit extends Record({
  id: undefined,
  stationId: undefined,
  stationAccountId: undefined,
  profit: undefined,
  profitSharingId: undefined,
  accountDay: undefined,
  accountType: undefined,
  userId: undefined,
  createdAt: undefined,
  updatedAt: undefined,
}, 'AccountProfit') {
  static fromJson(json) {
    let profit = new AccountProfit()
    return profit.withMutations((record) => {
      record.set('id', json.id)
      record.set('stationId', json.stationId)
      record.set('stationAccountId', json.stationAccountId)
      record.set('profit', json.profit)
      record.set('profitSharingId', json.profitSharingId)
      record.set('accountDay', moment(new Date(json.accountDay)).format('YYYY-MM-DD'))
      record.set('accountType', json.accountType)
      record.set('userId', json.userId)
      record.set('createdAt', json.createdAt)
      record.set('updatedAt', json.updatedAt)
    })
  }
}

/**** Constant ****/
{'fraction_non_alphanumeric': 0.13841851794314122, 'fraction_numerical': 0.0024856299518409195, 'mean_word_length': 4.37844611528822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2854390', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1949, 'n_words': 424}