hive_sql 1.0.0.pre.2 → 1.0.1

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: bd5bd8d219c1ad22da6b5d6b7abd76a65792d7d14f194990bda7e3e331e2ba76
4
- data.tar.gz: 6fbcc61ef42e6f19dfcf423597b20bfd1bd656c7d055c1cab2980156a94c7ac5
3
+ metadata.gz: be36232746b573c2cc3d705708967c221bad9321c0042ee5cd5d176e14972c1d
4
+ data.tar.gz: 442ad33603f8b64559d7ee6f8a884d3c08e762bf9ea6fc7c8892a8b98db48c25
5
5
  SHA512:
6
- metadata.gz: f83ac383174d7021b379fe82363342b2430db26e91714cae04402cc6fca90ac05990f705864d1cbef25c0078d193d3084b2ead582e350362173be96dfc8b7473
7
- data.tar.gz: a2398930b03034f4702ade35af0961c10ff776d04f03eb61a8640e7ca64869001c52f8fddf8f64abe60f23ca5e4f3840e6afb878d6911dcd29e99bbc99943b09
6
+ metadata.gz: a226b60838ad33fa4eb43beb4edd935511b1b1bbbabb084629b729ec4d1f7307a8891e38b7d939bfd141c4be329c5951fcefcbed8a8da002b4d12e4499215cd8
7
+ data.tar.gz: 9043c8ff22eebf9f46c42dc1fe446a8c48909dfe3f8b947e3aae8f493f4701b484da8b899f74b914e29686a44b4b3b7b5f23c11d4c2500e1975668f8d3bbf0f2
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  Access [HiveSQL.io](https://hivesql.io) data from your ruby/rails application.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/hive_sql.svg)](https://badge.fury.io/rb/hive_sql)
6
+ [![Inline docs](http://inch-ci.org/github/inertia186/hive_sql.png)](http://inch-ci.org/github/inertia186/hive_sql)
7
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/inertia186/hive_sql)
6
8
 
7
9
  ### How to Subscribe
8
10
 
@@ -53,6 +53,8 @@ require "hive_sql/models/tx/custom/community"
53
53
 
54
54
  require "hive_sql/models/vo/author_reward"
55
55
  require "hive_sql/models/vo/comment_benefactor_reward"
56
+ require "hive_sql/models/vo/comment_payout_update"
57
+ require "hive_sql/models/vo/comment_reward"
56
58
  require "hive_sql/models/vo/curation_reward"
57
59
  require "hive_sql/models/vo/fill_convert_request"
58
60
  require "hive_sql/models/vo/fill_order"
@@ -80,15 +80,15 @@ end
80
80
  # last_vote_time: datetime,
81
81
  # balance: varchar,
82
82
  # savings_balance: varchar,
83
- # sbd_balance: varchar,
84
- # sbd_seconds: integer,
85
- # sbd_seconds_last_update: datetime,
86
- # sbd_last_interest_payment: datetime,
87
- # savings_sbd_balance: varchar,
88
- # savings_sbd_seconds: integer,
89
- # savings_sbd_seconds_last_update: datetime,
90
- # savings_sbd_last_interest_payment: datetime,
91
- # savings_withdraw_requests: integer,
83
+ # hbd_balance: varchar,
84
+ # hbd_seconds: integer,
85
+ # hbd_seconds_last_update: datetime,
86
+ # hbd_last_interest_payment: datetime,
87
+ # savings_hbd_balance: varchar,
88
+ # savings_hbd_seconds: integer,
89
+ # savings_hbd_seconds_last_update: datetime,
90
+ # savings_hbd_last_interest_payment: datetime,
91
+ # savings_hithdraw_requests: integer,
92
92
  # vesting_shares: varchar,
93
93
  # vesting_withdraw_rate: varchar,
94
94
  # next_vesting_withdrawal: datetime,
@@ -109,7 +109,6 @@ end
109
109
  # net_rshares: integer,
110
110
  # abs_rshares: integer,
111
111
  # vote_rshares: integer,
112
- # children_abs_rshares: integer,
113
112
  # cashout_time: datetime,
114
113
  # max_cashout_time: datetime,
115
114
  # total_vote_weight: float,
@@ -118,11 +117,8 @@ end
118
117
  # curator_payout_value: money,
119
118
  # author_rewards: money,
120
119
  # net_votes: integer,
121
- # root_comment: varchar,
122
- # mode: varchar,
123
120
  # max_accepted_payout: money,
124
- # percent_steem_dollars: integer,
125
- # allow_replies: boolean,
121
+ # percent_hbd: integer,
126
122
  # allow_votes: boolean,
127
123
  # allow_curation_rewards: boolean,
128
124
  # beneficiaries: varchar_max,
@@ -131,11 +127,8 @@ end
131
127
  # pending_payout_value: money,
132
128
  # total_pending_payout_value: money,
133
129
  # active_votes: varchar_max,
134
- # replies: varchar_max,
135
- # author_reputation: integer,
136
130
  # promoted: varchar,
137
131
  # body_length: integer,
138
- # reblogged_by: varchar_max,
139
132
  # body_language: varchar,
140
133
  # dirty: boolean,
141
134
  # TS: ss_timestamp
@@ -19,18 +19,18 @@ end
19
19
  # virtual_supply: money,
20
20
  # current_supply: money,
21
21
  # confidential_supply: money,
22
- # current_sbd_supply: money,
23
- # confidential_sbd_supply: money,
24
- # total_vesting_fund_steem: money,
25
- # total_vesting_fund_steem_symbol: varchar,
22
+ # current_hbd_supply: money,
23
+ # confidential_hbd_supply: money,
24
+ # total_vesting_fund_hive: money,
25
+ # total_vesting_fund_hive_symbol: varchar,
26
26
  # total_vesting_shares: money,
27
27
  # total_vesting_shares_symbol: varchar,
28
- # total_reward_fund_steem: money,
28
+ # total_reward_fund_hive: money,
29
29
  # total_reward_shares2: varchar,
30
30
  # pending_rewarded_vesting_shares: varchar,
31
- # pending_rewarded_vesting_steem: varchar,
32
- # sbd_interest_rate: integer,
33
- # sbd_print_rate: integer,
31
+ # pending_rewarded_vesting_hive: varchar,
32
+ # hbd_interest_rate: integer,
33
+ # hbd_print_rate: integer,
34
34
  # average_block_size: integer,
35
35
  # maximum_block_size: integer,
36
36
  # current_aslot: integer,
@@ -41,5 +41,5 @@ end
41
41
  # vote_power_reserve_rate: integer,
42
42
  # current_reserve_ratio: integer,
43
43
  # vote_regeneration_per_day: integer,
44
- # steem_per_vest: money
44
+ # hive_per_vest: money
45
45
  # )
@@ -14,8 +14,8 @@ end
14
14
  # ID: integer,
15
15
  # tx_id: integer,
16
16
  # account: varchar,
17
- # reward_steem: money,
18
- # reward_sbd: money,
17
+ # reward_hive: money,
18
+ # reward_hbd: money,
19
19
  # reward_vests: money,
20
20
  # timestamp: datetime
21
21
  # )
@@ -16,7 +16,7 @@ end
16
16
  # author: varchar,
17
17
  # permlink: varchar,
18
18
  # max_accepted_payout: money,
19
- # percent_steem_dollars: integer,
19
+ # percent_hbd: integer,
20
20
  # allow_votes: boolean,
21
21
  # allow_curation_rewards: boolean,
22
22
  # timestamp: datetime
@@ -19,7 +19,7 @@ end
19
19
  # who: varchar,
20
20
  # receiver: varchar,
21
21
  # escrow_id: integer,
22
- # sdb_amount: money,
23
- # steem_amount: money,
22
+ # hdb_amount: money,
23
+ # hive_amount: money,
24
24
  # timestamp: datetime
25
25
  # )
@@ -15,8 +15,8 @@ end
15
15
  # tx_id: integer,
16
16
  # from: varchar,
17
17
  # to: varchar,
18
- # sdb_amount: money,
19
- # steem_amount: money,
18
+ # hdb_amount: money,
19
+ # hive_amount: money,
20
20
  # escrow_id: integer,
21
21
  # agent: varchar,
22
22
  # fee: money,
@@ -18,7 +18,7 @@ end
18
18
  # block_signing_key: varchar,
19
19
  # props_account_creation_fee: money,
20
20
  # props_maximum_block_size: integer,
21
- # props_sbd_interest_rate: integer,
21
+ # props_hbd_interest_rate: integer,
22
22
  # fee: money,
23
23
  # timestamp: datetime
24
24
  # )
@@ -16,7 +16,7 @@ end
16
16
  # timestamp: datetime,
17
17
  # author: varchar,
18
18
  # permlink: varchar,
19
- # sbd_payout: money,
20
- # steem_payout: money,
19
+ # hbd_payout: money,
20
+ # hive_payout: money,
21
21
  # vesting_payout: money
22
22
  # )
@@ -17,7 +17,7 @@ end
17
17
  # benefactor: varchar,
18
18
  # author: varchar,
19
19
  # permlink: varchar,
20
- # sbd_payout: money
21
- # steem_payout: money
20
+ # hbd_payout: money
21
+ # hive_payout: money
22
22
  # vesting_payout: decimal(18,6)
23
23
  # )
@@ -0,0 +1,17 @@
1
+ module HiveSQL
2
+ module Vo
3
+ class CommentPayoutUpdate < HiveSQL::SqlBase
4
+
5
+ self.table_name = :VOCommentPayoutUpdates
6
+
7
+ end
8
+ end
9
+ end
10
+
11
+ # Structure
12
+ #
13
+ # HiveSQL::Vo::CommentPayoutUpdate(
14
+ # ID: integer,
15
+ # author: varchar,
16
+ # permlink: varchar
17
+ # )
@@ -0,0 +1,19 @@
1
+ module HiveSQL
2
+ module Vo
3
+ class CommentReward < HiveSQL::SqlBase
4
+
5
+ self.table_name = :VOCommentRewards
6
+
7
+ end
8
+ end
9
+ end
10
+
11
+ # Structure
12
+ #
13
+ # HiveSQL::Vo::CommentPayoutUpdate(
14
+ # ID: integer,
15
+ # author: varchar,
16
+ # permlink: varchar
17
+ # payout: money
18
+ # payout_symnol: varchar
19
+ # )
@@ -2,7 +2,7 @@ module HiveSQL
2
2
  module Vo
3
3
  class ProposalPay < HiveSQL::SqlBase
4
4
 
5
- self.table_name = :VOProposalPay
5
+ self.table_name = :VOProposalPays
6
6
 
7
7
  end
8
8
  end
@@ -36,12 +36,12 @@ end
36
36
  # account_creation_fee: money,
37
37
  # account_creation_fee_symbol: varchar,
38
38
  # maximum_block_size: integer,
39
- # sbd_interest_rate: integer,
40
- # sbd_exchange_rate_base: money,
41
- # sbd_exchange_rate_base_symbol: varchar,
42
- # sbd_exchange_rate_quote: money,
43
- # sbd_exchange_rate_quote_symbol: varchar,
44
- # last_sbd_exchange_update: timestamp,
39
+ # hbd_interest_rate: integer,
40
+ # hbd_exchange_rate_base: money,
41
+ # hbd_exchange_rate_base_symbol: varchar,
42
+ # hbd_exchange_rate_quote: money,
43
+ # hbd_exchange_rate_quote_symbol: varchar,
44
+ # last_hbd_exchange_update: timestamp,
45
45
  # running_version: varchar,
46
46
  # hardfork_version_vote: varchar,
47
47
  # hardfork_time_vote: timestamp
@@ -1,3 +1,3 @@
1
1
  module HiveSQL
2
- VERSION = '1.0.0-2'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hive_sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Martin (inertia)
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -320,13 +320,9 @@ executables:
320
320
  extensions: []
321
321
  extra_rdoc_files: []
322
322
  files:
323
- - ".gitignore"
324
- - Gemfile
325
323
  - LICENSE
326
324
  - README.md
327
- - Rakefile
328
325
  - bin/hive_sql
329
- - hive_sql.gemspec
330
326
  - lib/hive_sql.rb
331
327
  - lib/hive_sql/models/account.rb
332
328
  - lib/hive_sql/models/block.rb
@@ -373,6 +369,8 @@ files:
373
369
  - lib/hive_sql/models/tx/witness_update.rb
374
370
  - lib/hive_sql/models/vo/author_reward.rb
375
371
  - lib/hive_sql/models/vo/comment_benefactor_reward.rb
372
+ - lib/hive_sql/models/vo/comment_payout_update.rb
373
+ - lib/hive_sql/models/vo/comment_reward.rb
376
374
  - lib/hive_sql/models/vo/curation_reward.rb
377
375
  - lib/hive_sql/models/vo/fill_convert_request.rb
378
376
  - lib/hive_sql/models/vo/fill_order.rb
@@ -391,7 +389,7 @@ homepage: https://github.com/inertia186/hive_sql
391
389
  licenses:
392
390
  - CC0-1.0
393
391
  metadata: {}
394
- post_install_message:
392
+ post_install_message:
395
393
  rdoc_options: []
396
394
  require_paths:
397
395
  - lib
@@ -402,13 +400,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
402
400
  version: '0'
403
401
  required_rubygems_version: !ruby/object:Gem::Requirement
404
402
  requirements:
405
- - - ">"
403
+ - - ">="
406
404
  - !ruby/object:Gem::Version
407
- version: 1.3.1
405
+ version: '0'
408
406
  requirements: []
409
- rubyforge_project:
410
- rubygems_version: 2.7.10
411
- signing_key:
407
+ rubygems_version: 3.0.8
408
+ signing_key:
412
409
  specification_version: 4
413
410
  summary: Ruby/Rails wrapper for HiveSQL.io
414
411
  test_files: []
data/.gitignore DELETED
@@ -1,58 +0,0 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
- /tmp/
12
-
13
- # Used by dotenv library to load environment variables.
14
- # .env
15
-
16
- # Ignore Byebug command history file.
17
- .byebug_history
18
-
19
- ## Specific to RubyMotion:
20
- .dat*
21
- .repl_history
22
- build/
23
- *.bridgesupport
24
- build-iPhoneOS/
25
- build-iPhoneSimulator/
26
-
27
- ## Specific to RubyMotion (use of CocoaPods):
28
- #
29
- # We recommend against adding the Pods directory to your .gitignore. However
30
- # you should judge for yourself, the pros and cons are mentioned at:
31
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
- #
33
- # vendor/Pods/
34
-
35
- ## Documentation cache and generated files:
36
- /.yardoc/
37
- /_yardoc/
38
- /doc/
39
- /rdoc/
40
-
41
- ## Environment normalization:
42
- /.bundle/
43
- /vendor/bundle
44
- /lib/bundler/man/
45
-
46
- # for a library or gem, you might want to ignore these files since the code is
47
- # intended to run in multiple environments; otherwise, check them in:
48
- Gemfile.lock
49
- .ruby-version
50
- .ruby-gemset
51
-
52
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
- .rvmrc
54
-
55
- # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
- # .rubocop-https?--*
57
-
58
- **/.DS_Store
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in hive_sql.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,579 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
- require 'hive_sql'
4
- require 'awesome_print'
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
10
- t.ruby_opts << if ENV['HELL_ENABLED']
11
- '-W2'
12
- else
13
- '-W1'
14
- end
15
- end
16
-
17
- task :default => :test
18
-
19
- task :console do
20
- exec "irb -r hive_sql -I ./lib"
21
- end
22
-
23
- namespace :created do
24
- desc 'Lists accounts created grouped by creator and date.'
25
- task :accounts, [:creator, :days_ago] do |t, args|
26
- now = Time.now.utc
27
- creator = args[:creator]
28
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
29
-
30
- accounts = HiveSQL::Tx::AccountCreate.all
31
-
32
- if !!creator || creator == '%'
33
- unless creator == '%'
34
- accounts = accounts.where(creator: creator)
35
- end
36
- elsif creator =~ /.*%.*/
37
- accounts = accounts.where('creator LIKE ?', creator)
38
- end
39
-
40
- accounts = accounts.where('timestamp > ?', after_timestamp)
41
- accounts = accounts.group('CAST(timestamp AS DATE)', :creator)
42
- accounts = accounts.order('cast_timestamp_as_date ASC')
43
-
44
- accounts = accounts.count
45
- puts "# Daily creation count by #{creator.nil? ? 'all account creators' : creator} since #{after_timestamp} ..."
46
- ap accounts
47
- puts "# Total accounts: #{accounts.values.sum}"
48
- end
49
-
50
- desc 'Lists custom_json_operations grouped by id and date.'
51
- task :custom_json, [:id, :days_ago, :min_count] do |t, args|
52
- now = Time.now.utc
53
- tid = args[:id]
54
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
55
- min_count = (args[:min_count] || 1).to_i
56
-
57
- customs = HiveSQL::Tx::Custom.all
58
-
59
- if !!tid && tid != '%' && tid =~ /.*%.*/
60
- customs = customs.where("tid LIKE ?", tid)
61
- elsif !!tid && tid != '%'
62
- customs = customs.where(tid: tid)
63
- end
64
-
65
- customs = customs.where('timestamp > ?', after_timestamp)
66
- customs = customs.group('CAST(timestamp AS DATE)', :tid)
67
- customs = customs.order('cast_timestamp_as_date ASC')
68
-
69
- customs = customs.count
70
-
71
- customs = customs.map do |k, v|
72
- [k, v] if v >= min_count
73
- end.compact.to_h
74
-
75
- puts "# Daily creation count by #{tid.nil? ? 'all custom_json_operation' : tid} since #{after_timestamp} ..."
76
- ap customs
77
- puts "# Total custom_json_operation: #{customs.values.sum}"
78
- end
79
- end
80
-
81
- desc 'Lists sum of transfers grouped by date, from, and to.'
82
- task :transfers, [:minimum_amount, :symbol, :days_ago] do |t, args|
83
- now = Time.now.utc
84
- minimum_amount = (args[:minimum_amount] || '1000000').to_f
85
- symbol = (args[:symbol] || 'HIVE').upcase
86
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
87
-
88
- # Only type: transfer; ignore savings, vestings
89
- transfers = HiveSQL::Tx::Transfer.where(type: 'transfer')
90
- transfers = transfers.where('amount > ?', minimum_amount)
91
- transfers = transfers.where('amount_symbol = ?', symbol)
92
- transfers = transfers.where('timestamp > ?', after_timestamp)
93
- transfers = transfers.group('CAST(timestamp AS DATE)', :from, :to)
94
- transfers = transfers.order('cast_timestamp_as_date ASC')
95
-
96
- puts "Daily transfer sum over #{'%.3f' % minimum_amount} #{symbol} since #{after_timestamp} ..."
97
- ap transfers.sum(:amount)
98
- end
99
-
100
- desc 'Lists sum of powered up grouped by date, from, and to.'
101
- task :powerup, [:minimum_amount, :symbol, :days_ago, :not_to_self] do |t, args|
102
- now = Time.now.utc
103
- minimum_amount = (args[:minimum_amount] || '500').to_f
104
- symbol = (args[:symbol] || 'HIVE').upcase
105
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
106
- not_to_self = (args[:not_to_self] || 'false') == 'true'
107
-
108
- minimum_amount = case symbol
109
- when 'MVESTS' then minimum_amount * 1e6 #TODO
110
- when 'VESTS' then minimum_amount # TODO
111
- when 'HIVE' then minimum_amount
112
- else; raise "Unknown symbol: #{symbol}"
113
- end
114
-
115
- # Only type: transfer; ignore savings, vestings
116
- transfers = HiveSQL::Tx::Transfer.where(type: 'transfer_to_vesting')
117
- transfers = transfers.where('amount > ?', minimum_amount)
118
- transfers = transfers.where('amount_symbol = ?', 'HIVE')
119
- transfers = transfers.where('timestamp > ?', after_timestamp)
120
- transfers = transfers.group('CAST(timestamp AS DATE)', :from, :to)
121
- transfers = transfers.order('cast_timestamp_as_date ASC')
122
-
123
- transfers = transfers.sum(:amount)
124
-
125
- if not_to_self
126
- transfers = transfers.map do |k, v|
127
- [k, v] if k[1] != k[2]
128
- end.compact.to_h
129
- end
130
-
131
- puts "# Daily transfer sum over #{'%.3f' % minimum_amount} #{symbol} #{not_to_self ? '' : 'not to self '}since #{after_timestamp} ..."
132
- ap transfers
133
- puts "# Total #{symbol}: #{transfers.values.sum}"
134
- end
135
-
136
- desc 'Lists sum of powered down grouped by date, from, and to.'
137
- task :powerdown, [:minimum_amount, :symbol, :days_ago, :not_to_self] do |t, args|
138
- now = Time.now.utc
139
- minimum_amount = (args[:minimum_amount] || '500').to_f
140
- symbol = (args[:symbol] || 'HIVE').upcase
141
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
142
- not_to_self = (args[:not_to_self] || 'false') == 'true'
143
-
144
- minimum_amount = case symbol
145
- when 'MVESTS' then minimum_amount * 1e6 #TODO
146
- when 'VESTS' then minimum_amount # TODO
147
- when 'HIVE' then minimum_amount
148
- else; raise "Unknown symbol: #{symbol}"
149
- end
150
-
151
- # Only type: transfer; ignore savings, vestings
152
- transfers = HiveSQL::Tx::Transfer.where(type: 'transfer_to_vesting')
153
- transfers = transfers.where('amount > ?', minimum_amount)
154
- transfers = transfers.where('amount_symbol = ?', 'HIVE')
155
- transfers = transfers.where('timestamp > ?', after_timestamp)
156
- transfers = transfers.group('CAST(timestamp AS DATE)', :from, :to)
157
- transfers = transfers.order('cast_timestamp_as_date ASC')
158
-
159
- transfers = transfers.sum(:amount)
160
-
161
- if not_to_self
162
- transfers = transfers.map do |k, v|
163
- [k, v] if k[1] != k[2]
164
- end.compact.to_h
165
- end
166
-
167
- puts "# Daily transfer sum over #{'%.3f' % minimum_amount} #{symbol} #{not_to_self ? '' : 'not to self '}since #{after_timestamp} ..."
168
- ap transfers
169
- puts "# Total #{symbol}: #{transfers.values.sum}"
170
- end
171
-
172
- desc 'Lists apps grouped by date, app/version.'
173
- task :apps, [:app, :days_ago] do |t, args|
174
- now = Time.now.utc
175
- app = args[:app]
176
- after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
177
-
178
- comments = HiveSQL::Comment.normalized_json
179
- comments = comments.app(app) if !!app
180
- comments = comments.where('created > ?', after_timestamp)
181
- comments = comments.group('CAST(created AS DATE)', "JSON_VALUE(json_metadata, '$.app')")
182
- comments = comments.order('cast_created_as_date ASC')
183
-
184
- matching = " matching \"#{app}\"" if !!app
185
- puts "Daily app#{matching} count since #{after_timestamp} ..."
186
- ap comments.count(:all)
187
- end
188
-
189
- desc 'Lists app names grouped by date, app/version.'
190
- task :app_names, [:app, :days_ago] do |t, args|
191
- now = Time.now.utc
192
- app = args[:app]
193
- after_timestamp = now - ((args[:days_ago] || '7').to_f * 86400)
194
-
195
- comments = HiveSQL::Comment.normalized_json
196
- comments = comments.app(app) if !!app
197
- comments = comments.where('created > ?', after_timestamp)
198
- comments = comments.group('CAST(created AS DATE)', "JSON_VALUE(json_metadata, '$.app')")
199
- comments = comments.order('cast_created_as_date ASC')
200
-
201
- matching = " matching \"#{app}\"" if !!app
202
- puts "# Daily app#{matching} count since #{after_timestamp} ..."
203
-
204
- app_names = {}
205
-
206
- comments.count(:all).each do |k, v|
207
- date, app = k
208
- if !!app && app.include?('/')
209
- name, version = app.split('/')
210
- app_names[[date, name]] ||= 0.0
211
- app_names[[date, name]] += v
212
- end
213
- end
214
-
215
- ap app_names
216
- end
217
-
218
- desc 'Do all crosschecks of given account.'
219
- task :crosscheck, [:account] do |t, args|
220
- account = args[:account]
221
-
222
- Rake::Task["crosscheck:powerdowns"].invoke(account)
223
- Rake::Task["crosscheck:powerups"].invoke(account)
224
- Rake::Task["crosscheck:transfers"].invoke(account)
225
- Rake::Task["crosscheck:vesting_from"].invoke(account)
226
- Rake::Task["crosscheck:vesting_to"].invoke(account)
227
- end
228
-
229
- namespace :crosscheck do
230
- desc 'List of accounts grouped by transfer count crosschecked by memo of given account.'
231
- task :transfers, [:account] do |t, args|
232
- exchanges = %w(bittrex poloniex openledger blocktrades deepcrypto8 gopax
233
- binanceexchange teambitwala changelly hitbtc-exchange korbit roomofsatoshi
234
- shapeshiftio)
235
- account = args[:account]
236
-
237
- if account.nil? || account == ''
238
- puts 'Account name required.'
239
- exit
240
- elsif exchanges.include? account
241
- puts 'That procedure is not recommended.'
242
- exit
243
- end
244
-
245
- all = HiveSQL::Tx::Transfer.where(type: 'transfer')
246
- transfers = all.where.not(memo: '')
247
- transfers = transfers.where(to: exchanges)
248
- transfers = if account =~ /%/
249
- table = HiveSQL::Tx::Transfer.arel_table
250
- transfers.where(table[:from].matches(account))
251
- else
252
- transfers.where(from: account)
253
- end
254
- crosscheck_transfers = all.where(memo: transfers.select(:memo))
255
-
256
- if transfers.none?
257
- puts "No match."
258
- else
259
- from = transfers.pluck(:from).uniq.join(', ')
260
- puts "Accounts grouped by transfer count using common memos as #{from} on common exchanges ..."
261
- ap crosscheck_transfers.group(:from).order('count_all').count(:all)
262
- end
263
- end
264
-
265
- desc 'List of accounts grouped by vesting transfers from a given account'
266
- task :vesting_from, [:account] do |t, args|
267
- account = args[:account]
268
-
269
- if account.nil? || account == ''
270
- puts 'Account name required.'
271
- exit
272
- end
273
-
274
- table = HiveSQL::Tx::Transfer.arel_table
275
- all = HiveSQL::Tx::Transfer.where(type: 'transfer_to_vesting')
276
- transfers = all.where(table[:from].not_eq(:to))
277
- transfers = transfers.where.not(to: '')
278
- transfers = if account =~ /%/
279
- table = HiveSQL::Tx::Transfer.arel_table
280
- transfers.where(table[:from].matches(account))
281
- else
282
- transfers.where(from: account)
283
- end
284
-
285
- if transfers.none?
286
- puts "No match."
287
- else
288
- from = transfers.pluck(:from).uniq.join(', ')
289
- puts "Accounts grouped by vesting transfer count from #{from} ..."
290
- ap transfers.group(:to).order('count_all').count(:all)
291
- end
292
- end
293
-
294
- desc 'List of accounts grouped by vesting transfers to a given account'
295
- task :vesting_to, [:account] do |t, args|
296
- account = args[:account]
297
-
298
- if account.nil? || account == ''
299
- puts 'Account name required.'
300
- exit
301
- end
302
-
303
- table = HiveSQL::Tx::Transfer.arel_table
304
- all = HiveSQL::Tx::Transfer.where(type: 'transfer_to_vesting')
305
- transfers = all.where(table[:from].not_eq(table[:to]))
306
- transfers = transfers.where.not(to: '')
307
- transfers = if account =~ /%/
308
- table = HiveSQL::Tx::Transfer.arel_table
309
- transfers.where(table[:to].matches(account))
310
- else
311
- transfers.where(to: account)
312
- end
313
-
314
- if transfers.none?
315
- puts "No match."
316
- else
317
- from = transfers.pluck(:to).uniq.join(', ')
318
- puts "Accounts grouped by vesting transfer count to #{from} ..."
319
- ap transfers.group(:from).order('count_all').count(:all)
320
- end
321
- end
322
-
323
- desc 'List of accounts grouped by powerdown sums crosschecked by given account.'
324
- task :powerdowns, [:account] do |t, args|
325
- account = args[:account]
326
-
327
- if account.nil? || account == ''
328
- puts 'Account name required.'
329
- exit
330
- end
331
-
332
- table = HiveSQL::Vo::FillVestingWithdraw.arel_table
333
- all = HiveSQL::Vo::FillVestingWithdraw.where(table[:from_account].not_eq(table[:to_account]))
334
- powerdowns = if account =~ /%/
335
- all.where(table[:from_account].matches(account))
336
- else
337
- all.where(from_account: account)
338
- end
339
-
340
- if powerdowns.none?
341
- puts "No match."
342
- else
343
- from = powerdowns.pluck(:from_account).uniq.join(', ')
344
- puts "Powerdowns grouped by sum from #{from} ..."
345
- ap powerdowns.group(:to_account).
346
- order('sum_try_parse_replace_withdrawn_vests_as_float').
347
- sum("TRY_PARSE(REPLACE(withdrawn, ' VESTS', '') AS float)")
348
- end
349
- end
350
-
351
- desc 'List of accounts grouped by powerup sums crosschecked by given account.'
352
- task :powerups, [:account] do |t, args|
353
- account = args[:account]
354
-
355
- if account.nil? || account == ''
356
- puts 'Account name required.'
357
- exit
358
- end
359
-
360
- table = HiveSQL::Vo::FillVestingWithdraw.arel_table
361
- all = HiveSQL::Vo::FillVestingWithdraw.where(table[:from_account].not_eq(table[:to_account]))
362
- powerups = if account =~ /%/
363
- all.where(table[:to_account].matches(account))
364
- else
365
- all.where(to_account: account)
366
- end
367
-
368
- if powerups.none?
369
- puts "No match."
370
- else
371
- to = powerups.pluck(:to_account).uniq.join(', ')
372
- puts "Powerups grouped by sum to #{to} ..."
373
- ap powerups.group(:from_account).
374
- order('sum_try_parse_replace_withdrawn_vests_as_float').
375
- sum("TRY_PARSE(REPLACE(withdrawn, ' VESTS', '') AS float)")
376
- end
377
- end
378
- end
379
-
380
- namespace :rewards do
381
- desc 'Lists author rewards grouped by date.'
382
- task :author, [:symbol, :days_ago, :author] do |t, args|
383
- now = Time.now.utc
384
- symbol = (args[:symbol] || 'HBD').upcase
385
- after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
386
- author = args[:author]
387
-
388
- rewards = HiveSQL::Vo::AuthorReward
389
- rewards = rewards.where('timestamp > ?', after_timestamp)
390
- rewards = rewards.group('CAST(timestamp AS DATE)')
391
- rewards = rewards.order('cast_timestamp_as_date ASC')
392
-
393
- if !!author
394
- if author =~ /%/
395
- rewards = rewards.where("author LIKE ?", author)
396
- else
397
- rewards = rewards.where(author: author)
398
- end
399
-
400
- puts "Daily #{author} reward #{symbol} sum grouped by date since #{after_timestamp} ..."
401
- else
402
- puts "Daily reward #{symbol} sum grouped by date since #{after_timestamp} ..."
403
- end
404
-
405
- rewards = case symbol
406
- when 'HBD' then rewards.sum(:sbd_payout)
407
- when 'HIVE' then rewards.sum(:steem_payout)
408
- when 'VESTS' then rewards.sum(:vesting_payout)
409
- when 'MVESTS'
410
- rewards.sum('vesting_payout / 1000000')
411
- else; puts "Unknown symbol: #{symbol}. Symbols supported: HBD, HIVE, VESTS, MVESTS"
412
- end
413
-
414
- ap rewards
415
- sum = rewards.values.sum
416
- puts "# Total rewards: %.3f %s (average: %.3f per day)" % [sum, symbol, (sum / rewards.size)]
417
- end
418
-
419
- desc 'Lists curation rewards grouped by date.'
420
- task :curation, [:symbol, :days_ago] do |t, args|
421
- now = Time.now.utc
422
- symbol = (args[:symbol] || 'MVESTS').upcase
423
- after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
424
-
425
- rewards = HiveSQL::Vo::CurationReward
426
- rewards = rewards.where('timestamp > ?', after_timestamp)
427
- rewards = rewards.group('CAST(timestamp AS DATE)')
428
- rewards = rewards.order('cast_timestamp_as_date ASC')
429
-
430
- puts "Daily curation reward #{symbol} sum grouped by date since #{after_timestamp} ..."
431
-
432
- case symbol
433
- when 'VESTS'
434
- ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float)")
435
- when 'MVESTS'
436
- ap rewards.sum("TRY_PARSE(REPLACE(reward, ' VESTS', '') AS float) / 1000000")
437
- else; puts "Unknown symbol: #{symbol}. Symbols supported: VESTS, MVESTS"
438
- end
439
- end
440
- end
441
-
442
- desc 'Lists proxied grouped by month.'
443
- task :proxied, [:days_ago] do |t, args|
444
- now = Time.now.utc
445
- after_timestamp = now - ((args[:days_ago] || '7').to_i * 86400)
446
-
447
- proxied = HiveSQL::Tx::AccountWitnessProxy
448
- proxied = proxied.where('timestamp > ?', after_timestamp)
449
- proxied = proxied.group("FORMAT(timestamp, 'yyyy-MM')", :proxy)
450
- proxied = proxied.order('format_timestamp_yyyy_mm ASC')
451
-
452
- puts "Daily proxied grouped by month since #{after_timestamp} ..."
453
-
454
- ap proxied.count(:all)
455
- end
456
-
457
- desc <<~EOF
458
- Claimed Rewards.
459
- Use the "account_name" of a user or '%' to match on any user.
460
- EOF
461
- task :claimed, [:account_name, :days_ago, :symbol] do |t, args|
462
- now = Time.now.utc
463
- account_name = args[:account_name] || '%'
464
- after_timestamp = now - ((args[:days_ago] || '30').to_i * 86400)
465
- symbol = (args[:symbol] || 'vests').downcase.to_sym
466
- claims = HiveSQL::Tx::ClaimRewardBalance.where('timestamp > ?', after_timestamp)
467
-
468
- claims = if account_name =~ /%/
469
- claims.where('account LIKE ?', account_name)
470
- else
471
- claims.where(account: account_name)
472
- end
473
-
474
- claims = case symbol
475
- when :vests then claims.where("reward_vests > 0")
476
- when :mvests then claims.where("reward_vests > 0")
477
- when :hive then claims.where("reward_steem > 0")
478
- when :hbd then claims.where("reward_sbd > 0")
479
- else; raise "Unknown symbol: #{symbol.to_s.upcase} (allowed: VESTS, MVESTS, HIVE, HBD)"
480
- end
481
-
482
- claims = claims.group("FORMAT(timestamp, 'yyyy-MM')")
483
- claims = claims.order('format_timestamp_yyyy_mm ASC')
484
-
485
- claims = case symbol
486
- when :vests then claims.sum(:reward_vests)
487
- when :mvests then claims.sum('reward_vests / 1000000')
488
- when :hive then claims.sum(:reward_steem)
489
- when :hbd then claims.sum(:reward_sbd)
490
- end
491
-
492
- puts "# Claimed rewards in #{symbol.to_s.upcase} sum grouped by month ..."
493
-
494
- ap claims
495
- puts "# Total claimed #{symbol}: #{claims.values.sum}"
496
- end
497
-
498
- desc <<~EOF
499
- Balance for given parties.
500
- Where "party_a" is the first account, "party_b" is the second account and "symbol" is a valid native symbol.
501
- EOF
502
- task :balance, [:party_a, :party_b, :symbol] do |t, args|
503
- party_a = args[:party_a]
504
- party_b = args[:party_b]
505
- symbol = args[:symbol].upcase
506
-
507
- balance_a = HiveSQL::Tx::Transfer.where(to: party_a, from: party_b, amount_symbol: symbol).sum(:amount).to_f
508
- balance_b = HiveSQL::Tx::Transfer.where(to: party_b, from: party_a, amount_symbol: symbol).sum(:amount).to_f
509
-
510
- puts "#{party_a}: %.3f #{symbol}, difference: %.3f #{symbol}" % [balance_a, (balance_a - balance_b)]
511
- puts "#{party_b}: %.3f #{symbol}, difference: %.3f #{symbol}" % [balance_b, (balance_b - balance_a)]
512
- end
513
-
514
- desc <<~EOF
515
- Top what ...
516
- Allowed \"what\" options: upvoted downvoted
517
- EOF
518
- task :top, [:what, :limit] do |t, args|
519
- what = args[:what].to_s.downcase.to_sym
520
- limit = (args[:limit] || '10').to_i
521
- since = 1.week.ago
522
-
523
- case what
524
- when :upvoted, :downvoted
525
- comments = HiveSQL::Comment.after(since)
526
- comments = if what == :upvoted
527
- comments.where('net_rshares > 0')
528
- comments = comments.order('sum_net_rshares DESC')
529
- elsif what == :downvoted
530
- comments.where('net_rshares < 0')
531
- comments = comments.order('sum_net_rshares ASC')
532
- end
533
-
534
- comments = comments.group(:author, :permlink, :created)
535
- comments = comments.limit(limit)
536
-
537
- comments = comments.sum(:net_rshares)
538
-
539
- comments.each do |k, v|
540
- url = "https://hive.blog/@#{k[0]}/#{k[1]}"
541
- created = (Time.now - k[2]) / 60 / 60 / 24
542
-
543
- puts "#{v}; #{created.round(2)} days ago: #{url}"
544
- end
545
- end
546
- end
547
-
548
- # Doesn't look like this table exists.
549
- # desc 'List conversion HBD conversion request sums grouped by day.'
550
- # task :convert, [:days_ago] do |t, args|
551
- # now = Time.now.utc
552
- # after_timestamp = now - ((args[:days_ago] || '3.5').to_f * 86400)
553
- #
554
- # converts = HiveSQL::Vo::FillConvertRequest
555
- # converts = converts.where('timestamp > ?', after_timestamp)
556
- # converts = converts.group('CAST(timestamp AS DATE)')
557
- # converts = converts.order('cast_timestamp_as_date ASC')
558
- #
559
- # puts "Daily conversion requests failled sum grouped by date since #{after_timestamp} ..."
560
- # ap converts.sum(:amount)
561
- # end
562
-
563
- desc 'Build a new version of the hive_sql gem.'
564
- task :build do
565
- exec 'gem build hive_sql.gemspec'
566
- end
567
-
568
- desc 'Publish the current version of the hive_sql gem.'
569
- task :push do
570
- exec "gem push hive_sql-#{HiveSQL::VERSION}.gem"
571
- end
572
-
573
- # We're not going to yank on a regular basis, but this is how it's done if you
574
- # really want a task for that for some reason.
575
-
576
- # desc 'Yank the current version of the hive_sql gem.'
577
- # task :yank do
578
- # exec "gem yank hive_sql -v #{HiveSQL::VERSION}"
579
- # end
@@ -1,41 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'hive_sql/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'hive_sql'
8
- spec.version = HiveSQL::VERSION
9
- spec.authors = ['Anthony Martin (inertia)']
10
- spec.email = ['hive_sql@martin-studio.com']
11
-
12
- spec.summary = %q{Ruby/Rails wrapper for HiveSQL.io}
13
- spec.description = %q{Rails compatible gem that provides full DB connection and models to HiveSQL.io}
14
- spec.homepage = 'https://github.com/inertia186/hive_sql'
15
- spec.license = 'CC0-1.0'
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
20
- spec.bindir = 'bin'
21
- spec.executables = 'hive_sql'
22
- spec.require_paths = ['lib']
23
-
24
- spec.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.1'
25
- spec.add_development_dependency 'rake', '~> 12.1', '>= 12.1.0'
26
- spec.add_development_dependency 'minitest-proveit', '~> 1.0', '>= 1.0.0'
27
- spec.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.3'
28
- spec.add_development_dependency 'minitest-line', '~> 0.6', '>= 0.6.4'
29
- spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
30
- spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.16'
31
- spec.add_development_dependency 'rb-readline', '~> 0.5', '>= 0.5.5'
32
- spec.add_development_dependency 'irb', '~> 1.0', '>= 1.0.0'
33
-
34
- spec.add_runtime_dependency 'nokogiri', ['~> 1.8']
35
- spec.add_runtime_dependency 'rest-client', ['~> 2.0']
36
- spec.add_runtime_dependency 'activerecord', ['>= 4', '< 6']
37
- spec.add_runtime_dependency 'tiny_tds', ['~> 2.1']
38
- spec.add_runtime_dependency 'activerecord-sqlserver-adapter', ['>= 4', '< 6']
39
- spec.add_runtime_dependency 'activesupport', ['>= 4', '< 6']
40
- spec.add_runtime_dependency 'awesome_print', '~> 1.7', '>= 1.7.0'
41
- end