Commit 2b07bc29 authored by nazarf's avatar nazarf

sync miners from exel

parent 733c2bc4
...@@ -31,6 +31,7 @@ gem 'bootstrap3-datetimepicker-rails', '~> 4.15.35' ...@@ -31,6 +31,7 @@ gem 'bootstrap3-datetimepicker-rails', '~> 4.15.35'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "httparty" gem "httparty"
gem 'whenever', require: false gem 'whenever', require: false
gem "google_drive"
group :development do group :development do
gem 'web-console', '~> 2.0' gem 'web-console', '~> 2.0'
......
...@@ -37,6 +37,8 @@ GEM ...@@ -37,6 +37,8 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts_as_list (1.1.0) acts_as_list (1.1.0)
activerecord (>= 4.2) activerecord (>= 4.2)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
airbrussh (1.4.1) airbrussh (1.4.1)
sshkit (>= 1.6.1, != 1.7.0) sshkit (>= 1.6.1, != 1.7.0)
arel (6.0.4) arel (6.0.4)
...@@ -89,6 +91,7 @@ GEM ...@@ -89,6 +91,7 @@ GEM
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
crass (1.0.6) crass (1.0.6)
debug_inspector (1.1.0) debug_inspector (1.1.0)
declarative (0.0.20)
devise (4.9.0) devise (4.9.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
...@@ -100,11 +103,59 @@ GEM ...@@ -100,11 +103,59 @@ GEM
digest (3.1.1) digest (3.1.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.8.1) execjs (2.8.1)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.15.5) ffi (1.15.5)
font-awesome-rails (4.7.0.8) font-awesome-rails (4.7.0.8)
railties (>= 3.2, < 8.0) railties (>= 3.2, < 8.0)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
google-apis-core (0.11.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-drive_v3 (0.37.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-sheets_v4 (0.22.0)
google-apis-core (>= 0.11.0, < 2.a)
google_drive (3.0.7)
google-apis-drive_v3 (>= 0.5.0, < 1.0.0)
google-apis-sheets_v4 (>= 0.4.0, < 1.0.0)
googleauth (>= 0.5.0, < 1.0.0)
nokogiri (>= 1.5.3, < 2.0.0)
googleauth (0.17.1)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.15)
haml (5.2.2) haml (5.2.2)
temple (>= 0.8.0) temple (>= 0.8.0)
tilt tilt
...@@ -122,6 +173,7 @@ GEM ...@@ -122,6 +173,7 @@ GEM
httparty (0.21.0) httparty (0.21.0)
mini_mime (>= 1.0.0) mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (0.9.5) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
io-wait (0.3.0) io-wait (0.3.0)
...@@ -134,6 +186,7 @@ GEM ...@@ -134,6 +186,7 @@ GEM
jquery-ui-rails (6.0.1) jquery-ui-rails (6.0.1)
railties (>= 3.2.16) railties (>= 3.2.16)
json (1.8.6) json (1.8.6)
jwt (2.7.0)
less (2.6.0) less (2.6.0)
commonjs (~> 0.2.7) commonjs (~> 0.2.7)
less-rails (4.0.0) less-rails (4.0.0)
...@@ -148,6 +201,7 @@ GEM ...@@ -148,6 +201,7 @@ GEM
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
memoist (0.16.2)
mime-types (3.4.1) mime-types (3.4.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1) mime-types-data (3.2023.0218.1)
...@@ -157,7 +211,9 @@ GEM ...@@ -157,7 +211,9 @@ GEM
minitest (5.15.0) minitest (5.15.0)
momentjs-rails (2.29.4.1) momentjs-rails (2.29.4.1)
railties (>= 3.1) railties (>= 3.1)
multi_json (1.15.0)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.3.0)
mysql2 (0.4.10) mysql2 (0.4.10)
nested_form (0.3.2) nested_form (0.3.2)
net-imap (0.2.2) net-imap (0.2.2)
...@@ -180,6 +236,8 @@ GEM ...@@ -180,6 +236,8 @@ GEM
mini_portile2 (~> 2.6.1) mini_portile2 (~> 2.6.1)
racc (~> 1.4) racc (~> 1.4)
orm_adapter (0.5.0) orm_adapter (0.5.0)
os (1.1.4)
public_suffix (4.0.7)
racc (1.6.2) racc (1.6.2)
rack (1.6.13) rack (1.6.13)
rack-test (0.6.3) rack-test (0.6.3)
...@@ -213,9 +271,16 @@ GEM ...@@ -213,9 +271,16 @@ GEM
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
rdoc (4.3.0) rdoc (4.3.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
responders (2.4.1) responders (2.4.1)
actionpack (>= 4.2.0, < 6.0) actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0)
retriable (3.1.2)
rexml (3.2.5)
ruby2_keywords (0.0.5)
ruby_parser (3.19.2) ruby_parser (3.19.2)
sexp_processor (~> 4.16) sexp_processor (~> 4.16)
sass (3.7.4) sass (3.7.4)
...@@ -233,6 +298,11 @@ GEM ...@@ -233,6 +298,11 @@ GEM
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0) rdoc (~> 4.0)
sexp_processor (4.16.1) sexp_processor (4.16.1)
signet (0.16.1)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simple_form (4.0.0) simple_form (4.0.0)
actionpack (> 4) actionpack (> 4)
activemodel (> 4) activemodel (> 4)
...@@ -253,6 +323,7 @@ GEM ...@@ -253,6 +323,7 @@ GEM
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.1.0) tilt (2.1.0)
timeout (0.3.2) timeout (0.3.2)
trailblazer-option (0.1.2)
turbolinks (5.2.1) turbolinks (5.2.1)
turbolinks-source (~> 5.2) turbolinks-source (~> 5.2)
turbolinks-source (5.2.0) turbolinks-source (5.2.0)
...@@ -263,6 +334,7 @@ GEM ...@@ -263,6 +334,7 @@ GEM
railties (>= 3.1) railties (>= 3.1)
tzinfo (1.2.11) tzinfo (1.2.11)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uber (0.1.0)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
warden (1.2.7) warden (1.2.7)
...@@ -272,6 +344,7 @@ GEM ...@@ -272,6 +344,7 @@ GEM
binding_of_caller (>= 0.7.2) binding_of_caller (>= 0.7.2)
railties (>= 4.0) railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
webrick (1.8.1)
whenever (1.0.0) whenever (1.0.0)
chronic (>= 0.6.3) chronic (>= 0.6.3)
will_paginate (3.3.1) will_paginate (3.3.1)
...@@ -295,6 +368,7 @@ DEPENDENCIES ...@@ -295,6 +368,7 @@ DEPENDENCIES
devise devise
devise-i18n devise-i18n
font-awesome-rails font-awesome-rails
google_drive
haml-rails haml-rails
httparty httparty
jbuilder (~> 2.0) jbuilder (~> 2.0)
......
...@@ -62,6 +62,14 @@ class MinersController < AdminController ...@@ -62,6 +62,14 @@ class MinersController < AdminController
end end
end end
def update_miner_from_exel
`rake "miners:get_miners_data"`
respond_to do |format|
format.html { redirect_to miners_url, notice: 'Miners was update' }
format.json { head :no_content }
end
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
......
- model_class = Miner - model_class = Miner
.page-header.refresh_pagination .page-header.refresh_pagination
=link_to "update miner from exel", update_miner_from_exel_path, class: 'btn btn-default btn-xs'
%table.table.table-striped.filtered_table %table.table.table-striped.filtered_table
%thead %thead
%tr %tr
......
This diff is collapsed.
{
"type": "service_account",
"project_id": "z-node-231511",
"private_key_id": "9309fbe56a39c8e0a52ee4f3c0f8de87668cd282",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDKntM3uDNp3yNZ\n6CQ6dK3pngpuNaMLx68k/fHma6OujFB2rhbdzmksWs1qPg1cYmeQo/EoPEU3CYNm\nayPbk/7Wz6JmUwNpchvJ2JhiL2cA1X0/KunZH41CrEPpYZTvi85jgRnJvWMqAEvV\nB8Aj+WyKyfadxccgkXsClvgUR78/Isvm7jUqNUV6Y/ozKpPVbDWoH2+qyG34X89P\nw31+rS86fpU9oy3+IAM7n32280cQCrLIMIUeZ5/Mw8njX1eYnnEnM1G3VL6jZJ1C\nL4wykrE9kfau8dkTamy1rs6uWsZJhXVeW7G56BTYYGG0BCM31FGBsh+SCARgHE8C\n1/IUC67FAgMBAAECggEAEVZSYmPQ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q/ODxoFvH4Uu\nPI01n3kLereNTdGhF6tdnisIbr4SoNAxDn+EqXiz31wDrZm8Ui1ZyOpB3Vx7NSGu\nX2ZHVExAa9QihcES/Zkf17dJGCiSaAC+Mc5GaqvfL/ONmNSN4hp/o8h0Z6AyntH5\nt7rD+3YgAXfYzPkBuJhLTg==\n-----END PRIVATE KEY-----\n",
"client_email": "znode-639@z-node-231511.iam.gserviceaccount.com",
"client_id": "103779981999599165389",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/znode-639%40z-node-231511.iam.gserviceaccount.com"
}
...@@ -34,6 +34,7 @@ Rails.application.routes.draw do ...@@ -34,6 +34,7 @@ Rails.application.routes.draw do
get '/miners_activity/:name', to: 'front#miners_activity', as: 'miners_activity' get '/miners_activity/:name', to: 'front#miners_activity', as: 'miners_activity'
get '/update_miner_activity/:name', to: 'front#update_miner_activity', as: 'update_miner_activity' get '/update_miner_activity/:name', to: 'front#update_miner_activity', as: 'update_miner_activity'
get '/update_miner_from_exel', to: 'miners#update_miner_from_exel', as: 'update_miner_from_exel'
root 'front#index' root 'front#index'
end end
...@@ -35,4 +35,60 @@ namespace :miners do ...@@ -35,4 +35,60 @@ namespace :miners do
end end
end end
end end
task get_miners_data: :environment do
session = GoogleDrive::Session.from_service_account_key("client_secret.json")
spreadsheet ||= session.spreadsheet_by_title("bsa_miners")
@worksheet = spreadsheet.worksheets.first
NAME = 1
IP_ADDRESS = 4
PORT = 5
ADDRESS = 6
PASS = 7
ALGORITHM = 8
IP_ADDRESS_2 = 9
PORT_2 = 10
ADDRESS_2 = 11
PASS_2 = 12
ALGORITHM_2 = 13
row = 2
col = 1
@worksheet.rows.each_with_index do |cell, index|
if @worksheet[index + row, NAME] == ""
break
end
miner = Miner.find_by(name: @worksheet[index + row, NAME])
if miner.present?
miner.update(
name: @worksheet[index + row, NAME],
ip_address: @worksheet[index + row, IP_ADDRESS],
port: @worksheet[index + row, PORT],
wallet_address: @worksheet[index + row, ADDRESS],
pass: @worksheet[index + row, PASS],
algorithm: @worksheet[index + row, ALGORITHM],
ip_address_2: @worksheet[index + row, IP_ADDRESS_2],
port_2: @worksheet[index + row, PORT_2],
wallet_address_2: @worksheet[index + row, ADDRESS_2],
pass_2: @worksheet[index + row, PASS_2],
algorithm_2: @worksheet[index + row, ALGORITHM_2])
else
Miner.create(
name: @worksheet[index + row, NAME],
ip_address: @worksheet[index + row, IP_ADDRESS],
port: @worksheet[index + row, PORT],
wallet_address: @worksheet[index + row, ADDRESS],
pass: @worksheet[index + row, PASS],
algorithm: @worksheet[index + row, ALGORITHM],
ip_address_2: @worksheet[index + row, IP_ADDRESS_2],
port_2: @worksheet[index + row, PORT_2],
wallet_address_2: @worksheet[index + row, ADDRESS_2],
pass_2: @worksheet[index + row, PASS_2],
algorithm_2: @worksheet[index + row, ALGORITHM_2])
end
end
end
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment