Commit 35d934d7 authored by nazarf's avatar nazarf

add auto import node for google sheet

git-svn-id: https://svn.sp-service.com.ua/svnroot/svn/node-stats/trunk@3 320591d9-fe85-4a77-9bad-1a723db14d60
parent 23df983f
...@@ -29,13 +29,13 @@ gem 'momentjs-rails', '>= 2.9.0' ...@@ -29,13 +29,13 @@ gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.15.35' 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 'json' gem 'json'
gem "google_drive"
group :development do group :development do
gem 'web-console', '~> 2.0' gem 'capistrano-faster-assets'
gem 'capistrano', '~> 3.7.2'
gem 'capistrano-faster-assets', '~> 1.0'
gem 'capistrano-bundler'
gem 'capistrano-rvm'
gem 'capistrano-rails' gem 'capistrano-rails'
gem 'capistrano-rvm'
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end end
...@@ -126,6 +126,11 @@ class NodesController < AdminController ...@@ -126,6 +126,11 @@ class NodesController < AdminController
end end
end end
def sync_node
Node.sync_node
redirect_to nodes_path
end
private private
......
class Node < ActiveRecord::Base class Node < ActiveRecord::Base
# has_secure_password # has_secure_password
BEFORE_IP = 0
ADDRESS = 1
START_AMOUNT_T = 2
START_AMOUNT_Z = 3
RPC_USER = 4
RPC_PASS = 5
ALLOW_IP = 6
PROXMOX_ID = 7
AFTER_DOMAIN = 8
AFTER_IP = 9
STATE = 10
def self.sync_node
session = GoogleDrive::Session.from_service_account_key("client_secret.json")
spreadsheet ||= session.spreadsheet_by_title("znode-instal-stats")
@worksheet = spreadsheet.worksheets.first
@worksheet[1..1000].rows.each do |row|
Node.create(name: row[AFTER_DOMAIN], domain: row[AFTER_DOMAIN], ipv4: row[BEFORE_IP], start_balance_t: row[START_AMOUNT_T],
start_balance_z: row[START_AMOUNT_Z], node_username: row[RPC_USER], node_password: row[RPC_PASS])
end
end
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
%h1 %h1
= model_class.model_name.human(count: 2).mb_chars.titleize = model_class.model_name.human(count: 2).mb_chars.titleize
= link_to 'refresh node', z_gettotalbalance_url, class: 'btn btn-success' = link_to 'refresh node', z_gettotalbalance_url, class: 'btn btn-success'
= link_to 'sync node', sync_node_url, class: 'btn btn-success'
%p=@command %p=@command
Investment: Investment:
......
{
"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/IUC67FAgMBAAECggEAEVZSYmPQ2mVCbsX4m5vc6a7L267xOufPf7h5mKrAgFtM\njesgKm3Sp/3uXQHe6Mxuv3yXp5wInB358ACI5UKePUkvmdZ5O0ONRycmWs24NY+5\nk3cbjVLa0R1RA54wPT2sNO1uBHS/uxn4DcwHpSG0J5KtFxuTifYzcqmc+TdDu6Ya\nZM1eDW7y2EmQlDx83N7p3tzpM80y44/kG4Ac5SLWKhwTpEy9kvqonK1HhoTWOC18\n9jn81/U6X3ifq2CLnHEQkpu0LypNI/bR6OYmg8sRkeHgoVMzy7NSEjICLhBm9ha7\n8ZeMaoegAr7kPJKnjvW3ZR/SG0WRT2Zpis4Kin4NXQKBgQD71a3+zJfz56QDOmU0\nHvAm+3uVf3+uLwSmcgaWmPxLzzA5oPHt67gcF6GlBaQ967opT9UKMEQvb1bofExl\nIOh4qZ6g/XW75ChSanvBG/ZE6ZyNKzboAXYNoRldnIQOEGAPIcI6beEm5l1WEjl9\nvkeNADyHIyRVPRJkTHLBEORzewKBgQDN+MMOmMteXDUsl1y8Rz3M0wNC8BX/nmCb\ndvc2LtpD/YhwMvXqlDLQNUSkpMDP2SOzWIpUuN/vbXbm+NxdBPzKiLzXy3SRNtCH\nircnFEldsPI1Vy6GyDDyUHXFy8wsQ0tw54Mz6U+RNawcKswtZdS6oxB/I0opOff2\njouJ04qyvwKBgHdHeTcjLqGuyKdixEaQlMzR9nITxqT4zioL/gTchztc8gmJqq03\nJafgpYZlCqrteOpSTqSZweH5yV8qaIDJunJUXLcB9f69jT+kAeOwW8++GpFes43m\nC0VfVYVaOc3zgZwJMFa+bpMfL3wx+5sMQhWN1B1pzq60035AG2ZImvv7AoGAKxKP\nb9kCBlyP/iA1E2ZuhQvHjdL5NrhfCYPKVLldiYRWaOgvRvvw2FubXDbb31tQPOwS\nGX+DzOT+TXTTWFx3pL8Nhq8UVF27I+0dOf3jDcW4EPGHWEY6/iFXT6K7srHr79Nq\nO4vZyMsJj+ZfRksaPmFlTMELfC2ULipHAe6L/a8CgYBGQUlpazSjq/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"
}
# config valid only for current version of Capistrano # config valid only for current version of Capistrano
lock '3.7.2' lock '3.11.0'
# DEPLOY # DEPLOY
set :application, 'node-statistic' set :application, 'node-statistic'
# set :deploy_to, '/var/www/amaox' # Default deploy_to directory is /var/www/my_app_name # set :deploy_to, '/var/www/amaox' # Default deploy_to directory is /var/www/my_app_name
set :repo_url, 'http://svn.sp-service.com.ua/svnroot/svn/base_site/trunk' set :repo_url, 'https://svn.sp-service.com.ua/svnroot/svn/node-stats/trunk'
# set :format, :pretty # Default value for :format is :pretty # set :format, :pretty # Default value for :format is :pretty
# set :log_level, :debug # Default value for :log_level is :debug # set :log_level, :debug # Default value for :log_level is :debug
# set :pty, true # Default value for :pty is false # set :pty, true # Default value for :pty is false
......
server '45.77.137.182', user: 'deploy', roles: %w{app db web} server '194.44.41.195', user: 'deploy', roles: %w{app db web}
# set :rvm_custom_path, '/usr/local/rvm' # only needed if not detected # set :rvm_custom_path, '/usr/local/rvm' # only needed if not detected
...@@ -16,6 +16,7 @@ Rails.application.routes.draw do ...@@ -16,6 +16,7 @@ Rails.application.routes.draw do
controller :nodes do controller :nodes do
get 'set_t_address' => :set_t_address, as: 'set_t_address' get 'set_t_address' => :set_t_address, as: 'set_t_address'
get 'z_gettotalbalance' => :z_gettotalbalance, as: 'z_gettotalbalance' get 'z_gettotalbalance' => :z_gettotalbalance, as: 'z_gettotalbalance'
get 'sync_node' => :sync_node, as: 'sync_node'
get 'return_amount' => :return_amount, as: 'return_amount' get 'return_amount' => :return_amount, as: 'return_amount'
end end
resources :amount_sends resources :amount_sends
......
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