Class: Cns::Bigquery

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/cns/bigquery.rb

Overview

classe para processar bigquery

Constant Summary collapse

BD =
'hernanirvaz.coins'
FO =
File.expand_path("~/#{File.basename($PROGRAM_NAME)}.log")
TB =
{
  netht: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value gas gasprice gasused iserror txreceipt_status input contractaddress dias],
  hetht: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value gas gasPrice gasUsed isError txreceipt_status input contractAddress],
  nethi: %w[txhash blocknumber timestamp axfrom axto iax value contractaddress input type gas gasused traceid iserror errcode dias],
  hethi: %i[hash blockNumber timeStamp from to iax value contractAddress input type gas gasUsed traceId isError errCode],
  nethp: %w[blocknumber timestamp blockreward iax dias],
  hethp: %i[blockNumber timeStamp blockReward iax],
  nethw: %w[withdrawalindex validatorindex address amount blocknumber timestamp dias],
  hethw: %i[withdrawalIndex validatorIndex address amount blockNumber timeStamp],
  nethk: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value tokenname tokensymbol tokendecimal gas gasprice gasused input contractaddress dias],
  hethk: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value tokenName tokenSymbol tokenDecimal gas gasPrice gasUsed input contractAddress],
  neost: %w[gseq aseq bnum time contract action acfrom acto iax amount moeda memo dias],
  heost: %i[global_action_seq account_action_seq block_num block_time account name from to iax quantity moe memo],
  cdet: %w[txid time tp user btc eur dtc dias],
  hdet: %i[trade_id successfully_finished_at type username btc eur trade_marked_as_paid_at],
  cdel: %w[txid time tp add moe qt fee],
  hdel: %i[nxid time tp add moe qtd fee],
  cust: %w[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers dias],
  hust: %i[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers],
  cusl: %w[txid refid time type aclass asset amount fee],
  husl: %i[txid refid time type aclass asset amount fee]
}.freeze
TL =

para testes bigquery

{
  ins: 'INSERT',
  exo: false,
  est: '', # limit 228',
  esi: '', # limit 22',
  esp: '', # limit 72',
  esw: '', # limit 2350',
  esk: '', # limit 20',
  gmt: '', # limit 1091',
  ust: '', # limit 182',
  usl: '', # limit 448',
  det: '', # limit 27',
  del: '' # limit 16'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pop) ⇒ Bigquery

Returns API bigquery.

Parameters:

  • pop (Thor::CoreExt::HashWithIndifferentAccess)

    opcoes trabalho

Options Hash (pop):

  • :h (Hash) — default: {}

    configuracao ajuste reposicionamento temporal

  • :v (Boolean) — default: false

    mostra transacoes trades & ledger?

  • :t (Boolean) — default: false

    mostra transacoes todas ou somente novas?



63
64
65
66
67
68
# File 'lib/cns/bigquery.rb', line 63

def initialize(pop)
  # usa env GOOGLE_APPLICATION_CREDENTIALS para obter credentials
  # @see https://cloud.google.com/bigquery/docs/authentication/getting-started
  @api = Google::Cloud::Bigquery.new
  @ops = pop.transform_keys(&:to_sym)
end

Instance Attribute Details

#apiGoogle::Cloud::Bigquery, ... (readonly)

Returns:

  • (Google::Cloud::Bigquery)

    API bigquery

  • (Google::Cloud::Bigquery::QueryJob)

    job bigquery

  • (Thor::CoreExt::HashWithIndifferentAccess)

    opcoes trabalho

  • (Google::Cloud::Bigquery::Data)

    resultado do SQL



56
57
58
# File 'lib/cns/bigquery.rb', line 56

def api
  @api
end

#jobGoogle::Cloud::Bigquery, ... (readonly)

Returns:

  • (Google::Cloud::Bigquery)

    API bigquery

  • (Google::Cloud::Bigquery::QueryJob)

    job bigquery

  • (Thor::CoreExt::HashWithIndifferentAccess)

    opcoes trabalho

  • (Google::Cloud::Bigquery::Data)

    resultado do SQL



56
57
58
# File 'lib/cns/bigquery.rb', line 56

def job
  @job
end

#opsGoogle::Cloud::Bigquery, ... (readonly)

Returns:

  • (Google::Cloud::Bigquery)

    API bigquery

  • (Google::Cloud::Bigquery::QueryJob)

    job bigquery

  • (Thor::CoreExt::HashWithIndifferentAccess)

    opcoes trabalho

  • (Google::Cloud::Bigquery::Data)

    resultado do SQL



56
57
58
# File 'lib/cns/bigquery.rb', line 56

def ops
  @ops
end

Instance Method Details

#msethObject

mostra situacao completa entre etherscan & bigquery



81
82
83
# File 'lib/cns/bigquery.rb', line 81

def mseth
  apies.mresumo_simples
end

#mskrkObject

mostra situacao completa entre kraken/etherscan & bigquery



76
77
78
# File 'lib/cns/bigquery.rb', line 76

def mskrk
  [apius, apies].each(&:mresumo)
end

#mtudoObject

mostra situacao completa entre kraken/bitcoinde/paymium/therock/etherscan/greymass & bigquery



71
72
73
# File 'lib/cns/bigquery.rb', line 71

def mtudo
  [apius, apide, apies].each(&:mresumo)
end

#pcethObject

insere dados novos etherscan no bigquery (output to file)



106
107
108
# File 'lib/cns/bigquery.rb', line 106

def pceth
  File.open(FO, mode: 'a') { |o| o.puts("#{tct} #{peth(apiec)}") }
end

#ptudoObject

insere dados novos kraken/bitcoinde/etherscan/greymass no bigquery



91
92
93
# File 'lib/cns/bigquery.rb', line 91

def ptudo
  puts("#{tct} #{pus}, #{pde}, #{peth(apies)}")
end

#pwethObject

insere dados novos etherscan no bigquery



101
102
103
# File 'lib/cns/bigquery.rb', line 101

def pweth
  puts("#{tct} #{peth(apies)}")
end

#pwkrkObject

insere dados novos kraken/etherscan no bigquery



96
97
98
# File 'lib/cns/bigquery.rb', line 96

def pwkrk
  puts("#{tct} #{pus}, #{peth(apies)}")
end

#tctString

Returns texto inicial transacoes.

Returns:

  • (String)

    texto inicial transacoes



86
87
88
# File 'lib/cns/bigquery.rb', line 86

def tct
  Time.now.strftime('TRANSACOES  %Y-%m-%d %H:%M:%S')
end