Class: Cns::Bigquery

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

Overview

classe para processar bigquery

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?



27
28
29
30
31
32
# File 'lib/cns/bigquery.rb', line 27

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
end

Instance Attribute Details

#apiGoogle::Cloud::Bigquery (readonly)

Returns API bigquery.

Returns:

  • (Google::Cloud::Bigquery)

    API bigquery



14
15
16
# File 'lib/cns/bigquery.rb', line 14

def api
  @api
end

#jobGoogle::Cloud::Bigquery::QueryJob (readonly)

Returns job bigquery.

Returns:

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

    job bigquery



16
17
18
# File 'lib/cns/bigquery.rb', line 16

def job
  @job
end

#opsThor::CoreExt::HashWithIndifferentAccess (readonly)

Returns opcoes trabalho.

Returns:

  • (Thor::CoreExt::HashWithIndifferentAccess)

    opcoes trabalho



18
19
20
# File 'lib/cns/bigquery.rb', line 18

def ops
  @ops
end

#sqrGoogle::Cloud::Bigquery::Data (readonly)

Returns resultado do SQL.

Returns:

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

    resultado do SQL



20
21
22
# File 'lib/cns/bigquery.rb', line 20

def sqr
  @sqr
end

Instance Method Details

#mostra_sethObject

mostra situacao completa entre etherscan & bigquery



52
53
54
# File 'lib/cns/bigquery.rb', line 52

def mostra_seth
  apies.mostra_resumo
end

#mostra_skrkObject

mostra situacao completa entre kraken/etherscan & bigquery



46
47
48
49
# File 'lib/cns/bigquery.rb', line 46

def mostra_skrk
  apius.mostra_resumo
  apies.mostra_resumo
end

#mostra_tudoObject

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



35
36
37
38
39
40
41
42
43
# File 'lib/cns/bigquery.rb', line 35

def mostra_tudo
  apius.mostra_resumo
  apide.mostra_resumo
  #apifr.mostra_resumo
  #apimt.mostra_resumo
  apies.mostra_resumo
  apigm.mostra_resumo
  #apibc.mostra_resumo
end

#processa_cethObject

insere (caso existam) dados novos etherscan no bigquery (output to file)



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

def processa_ceth
  str = processa_ethc
  File.open(FO, mode: 'a') { |out| out.puts(trs_ini + str) }
end

#processa_tudoObject

insere (caso existam) dados novos kraken/bitcoinde/paymium/therock/etherscan/greymass/beaconchain no bigquery



62
63
64
65
# File 'lib/cns/bigquery.rb', line 62

def processa_tudo
  str = processa_us + ", " + processa_de + ", " + processa_eth + ", " + processa_eos
  puts(trs_ini + str)
end

#processa_wethObject

insere (caso existam) dados novos etherscan no bigquery



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

def processa_weth
  str = processa_eth
  puts(trs_ini + str)
end

#processa_wkrkObject

insere (caso existam) dados novos kraken/etherscan no bigquery



68
69
70
71
# File 'lib/cns/bigquery.rb', line 68

def processa_wkrk
  str = processa_us + ", " + processa_eth
  puts(trs_ini + str)
end

#trs_iniString

Returns texto inicial transacoes.

Returns:

  • (String)

    texto inicial transacoes



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

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