etht 0.1.6 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f58f14834a4fe6a2b700d12029a4bf6a59142961ae668853698d4879da51728
4
- data.tar.gz: 511eb750d417812fbd074499fdd7734c5c146e2558f0ac1fb9a9c017b74a476a
3
+ metadata.gz: 3684c2c8ef10db43c6a2ef339ff4066bf3937198c497f9f6e7d2b8f67889a606
4
+ data.tar.gz: 5885a6b55577b25fbb5437b293f69e4a6cefe2e863a5063aca2ebc7ab3c67d1f
5
5
  SHA512:
6
- metadata.gz: 33e1a218d03fa87bc4ce457c1c4b922ac2d9d3f6d3adbcc4fce4cabf3c2197f1e34a32e1a7e11a209a13e06b41003340a57373f5c23d2cf96ad09b2e46cfb3bd
7
- data.tar.gz: 03dbc955e3ac7fef1f3f17b50c2ca9b40b2f333e84f6d0569fc90f19eea32b7c5754eb24a96693344a08006942b455d322f4820fb0fd6af1fc7281b5ae55afa2
6
+ metadata.gz: 11d672fb263089adc466c30541af7b3218f581d960b2ddc6128e2ddbb958d8c349e70db972f8c569fc8d169d5ebf0c34afb43eab289682453d0315fcfa441360
7
+ data.tar.gz: b3ccdf480d22be07f6680362b9ca392821fb0cb29eec8851175c0edd938e84b958f4b5b2cdcbd26bafdb65e742165b87d6bc1c79e58f0bd6094ad3826743439e
@@ -0,0 +1,5 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ rvm:
5
+ - 2.7.0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- etht (0.1.6)
4
+ etht (0.1.11)
5
5
  faraday
6
6
  google-cloud-bigquery
7
7
  json
@@ -18,7 +18,7 @@ GEM
18
18
  declarative-option (0.1.0)
19
19
  faraday (1.0.1)
20
20
  multipart-post (>= 1.2, < 3)
21
- google-api-client (0.43.0)
21
+ google-api-client (0.44.0)
22
22
  addressable (~> 2.5, >= 2.5.1)
23
23
  googleauth (~> 0.9)
24
24
  httpclient (>= 2.8.1, < 3.0)
@@ -53,7 +53,7 @@ GEM
53
53
  multi_json (1.15.0)
54
54
  multipart-post (2.1.1)
55
55
  os (1.1.1)
56
- public_suffix (4.0.5)
56
+ public_suffix (4.0.6)
57
57
  rake (12.3.3)
58
58
  representable (3.0.4)
59
59
  declarative (< 0.1.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Etht
1
+ # Etht [![Build Status](https://travis-ci.com/hernanirvaz/etht.svg?branch=master)](https://travis-ci.com/hernanirvaz/etht)
2
2
 
3
3
  Arquiva eth-transactions no bigquery. Pode ajustar dias para reposicionamento temporal.
4
4
 
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ # frozen_string_literal: true
2
+
3
+ require('bundler/gem_tasks')
4
+ task(default: :build)
@@ -15,6 +15,8 @@ module Etht
15
15
  attr_reader :job
16
16
  # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
17
17
  attr_reader :ops
18
+ # @return (see sql)
19
+ attr_reader :sqr
18
20
 
19
21
  # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
20
22
  # @option pop [Hash] :h ({}) configuracao ajuste reposicionamento temporal
@@ -56,19 +58,19 @@ module Etht
56
58
  def etht_ins
57
59
  "insert #{BD}.etht(blocknumber,timestamp,txhash,nonce,blockhash,transactionindex,axfrom,axto,value,gas," \
58
60
  'gasprice,iserror,txreceipt_status,input,contractaddress,cumulativegasused,gasused,confirmations,dias' \
59
- ") VALUES(#{transacoes.norml.map { |e| etht_val1(e) }.join(',')})"
61
+ ") VALUES#{transacoes.norml.map { |e| etht_val1(e) }.join(',')}"
60
62
  end
61
63
 
62
64
  # @return [String] comando insert SQL formatado ethk (trx token)
63
65
  def ethk_ins
64
66
  "insert #{BD}.ethk(blocknumber,timestamp,txhash,nonce,blockhash,axfrom,contractaddress,axto,value,tokenname," \
65
67
  'tokensymbol,tokendecimal,transactionindex,gas,gasprice,gasused,cumulativegasused,input,confirmations,dias' \
66
- ") VALUES(#{transacoes.token.map { |e| ethk_val1(e) }.join(',')})"
68
+ ") VALUES#{transacoes.token.map { |e| ethk_val1(e) }.join(',')}"
67
69
  end
68
70
 
69
71
  # @return [String] valores formatados etht (trx normais parte1)
70
72
  def etht_val1(hes)
71
- "#{Integer(hes['blockNumber'])}," \
73
+ "(#{Integer(hes['blockNumber'])}," \
72
74
  "#{Integer(hes['timeStamp'])}," \
73
75
  "'#{hes['hash']}'," \
74
76
  "#{Integer(hes['nonce'])}," \
@@ -94,12 +96,12 @@ module Etht
94
96
  def etht_val3(hes)
95
97
  "#{hes['contractAddress'].length.zero? ? 'null' : "'#{hes['contractAddress']}'"}," \
96
98
  "0,cast('#{hes['gasUsed']}' as numeric),0," \
97
- "#{Integer(ops[:h][hes['blockNumber']] || 0)}"
99
+ "#{Integer(ops[:h][hes['blockNumber']] || 0)})"
98
100
  end
99
101
 
100
102
  # @return [String] valores formatados ethk (trx token parte1)
101
103
  def ethk_val1(hes)
102
- "#{Integer(hes['blockNumber'])}," \
104
+ "(#{Integer(hes['blockNumber'])}," \
103
105
  "#{Integer(hes['timeStamp'])}," \
104
106
  "'#{hes['hash']}'," \
105
107
  "#{Integer(hes['nonce'])}," \
@@ -126,34 +128,35 @@ module Etht
126
128
  "cast('#{hes['gasPrice']}' as numeric)," \
127
129
  "cast('#{hes['gasUsed']}' as numeric),0," \
128
130
  "#{hes['input'].length.zero? ? 'null' : "'#{hes['input']}'"},0," \
129
- "#{Integer(ops[:h][hes['blockNumber']] || 0)}"
131
+ "#{Integer(ops[:h][hes['blockNumber']] || 0)})"
130
132
  end
131
133
 
132
134
  # cria job bigquery & verifica execucao
133
135
  #
134
- # @param [String] sql a executar
136
+ # @param cmd (see sql)
135
137
  # @return [Boolean] job ok?
136
- def job?(sql)
137
- @job = api.query_job(sql)
138
+ def job?(cmd)
139
+ @job = api.query_job(cmd)
138
140
  @job.wait_until_done!
139
141
  puts(@job.error['message']) if @job.failed?
140
142
  @job.failed?
141
143
  end
142
144
 
143
- # cria Data Manipulation Language (DML) job bigquery
145
+ # cria Structured Query Language (SQL) job bigquery
144
146
  #
145
- # @param (see job?)
146
- # @return [Integer] numero linhas afetadas
147
- def dml(sql)
148
- job?(sql) ? 0 : job.num_dml_affected_rows
147
+ # @param [String] cmd comando SQL a executar
148
+ # @param [String] red resultado quando SQL tem erro
149
+ # @return [Google::Cloud::Bigquery::Data] resultado do SQL
150
+ def sql(cmd, red = [])
151
+ @sqr = job?(cmd) ? red : job.data
149
152
  end
150
153
 
151
- # cria Structured Query Language (SQL) job bigquery
154
+ # cria Data Manipulation Language (DML) job bigquery
152
155
  #
153
- # @param (see job?)
154
- # @return [Array<Hash>] resultados do SQL
155
- def sql(sql)
156
- job?(sql) ? [] : job.data
156
+ # @param cmd (see sql)
157
+ # @return [Integer] numero linhas afetadas
158
+ def dml(cmd)
159
+ job?(cmd) ? 0 : job.num_dml_affected_rows
157
160
  end
158
161
  end
159
162
  end
@@ -22,7 +22,6 @@ module Etht
22
22
  @api = Etherscan.new
23
23
  @dbq = dad
24
24
  @ops = pop
25
- p(ops)
26
25
  end
27
26
 
28
27
  # @return [Array<Hash>] todos os dados etherscan - saldos & transacoes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Etht
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etht
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-22 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ extra_rdoc_files: []
119
119
  files:
120
120
  - ".gitignore"
121
121
  - ".rubocop.yml"
122
+ - ".travis.yml"
122
123
  - CODE_OF_CONDUCT.md
123
124
  - Gemfile
124
125
  - Gemfile.lock