smartkiosk-server 0.10.14 → 0.10.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,11 @@ ActiveAdmin.register Terminal do
49
49
  end
50
50
  end
51
51
 
52
+ member_action(:session_records,
53
+ :method => :get,
54
+ :title => I18n.t('smartkiosk.admin.panels.terminals.all_session_records')
55
+ )
56
+
52
57
  member_action(:upgrade_build,
53
58
  :method => :get,
54
59
  :title => I18n.t('smartkiosk.admin.panels.terminals.upgrade')
@@ -351,6 +356,24 @@ ActiveAdmin.register Terminal do
351
356
  end
352
357
  end
353
358
 
359
+ panel I18n.t('smartkiosk.admin.panels.terminals.session_records') do
360
+ table_for(terminal.session_records[0..20], :i18n => SessionRecord) do |t|
361
+ t.column :started_at do |x|
362
+ Time.at(x.started_at).strftime("%d.%m.%Y %H:%M:%S")
363
+ end
364
+ t.column :upstream
365
+ t.column :downstream
366
+ t.column :time
367
+ end
368
+
369
+ div(:class => 'more') do
370
+ text_node link_to(
371
+ I18n.t('smartkiosk.admin.panels.terminals.all_session_records'),
372
+ session_records_admin_terminal_path(terminal.id)
373
+ )
374
+ end
375
+ end
376
+
354
377
  panel I18n.t('activerecord.models.collection.other') do
355
378
  table_for(terminal.collections.limit(20), :i18n => Collection) do |t|
356
379
  t.column :cash_sum
@@ -0,0 +1,10 @@
1
+ class SessionRecordsController < ApplicationController
2
+ before_filter :authenticate_terminal
3
+
4
+ def create
5
+ session = @terminal.session_records.create! params[:session_record]
6
+ render :text => session.id, :status => 200
7
+ rescue ActiveRecord::RecordInvalid
8
+ render :text => nil, :status => 400
9
+ end
10
+ end
@@ -20,7 +20,8 @@ class TerminalPingsController < ApplicationController
20
20
  :modified_at => profile.updated_at
21
21
  },
22
22
  :orders => @terminal.terminal_orders.unsent.as_json(:only => [:id, :keyword, :args, :created_at]),
23
- :update_providers => remote_timestamp.blank? || local_timestamp.to_i > remote_timestamp.to_i # to drop microseconds
23
+ :update_providers => remote_timestamp.blank? || local_timestamp.to_i > remote_timestamp.to_i, # to drop microseconds
24
+ :last_session_started_at => @terminal.last_session_started_at
24
25
  }
25
26
 
26
27
  render :json => response
@@ -0,0 +1,24 @@
1
+ class SessionRecord < ActiveRecord::Base
2
+ #
3
+ # RELATIONS
4
+ #
5
+ belongs_to :terminal
6
+
7
+ #
8
+ # VALIDATIONS
9
+ #
10
+ validates :terminal, :presence => true
11
+ validates :message_id, :presence => true, :uniqueness => true
12
+ validates :started_at, :presence => true
13
+ validates :upstream, :presence => true
14
+ validates :downstream, :presence => true
15
+ validates :time, :presence => true
16
+
17
+ after_create do
18
+ if terminal.last_session_started_at.blank? ||
19
+ self.started_at > terminal.last_session_started_at
20
+
21
+ terminal.update_attribute(:last_session_started_at, self.started_at)
22
+ end
23
+ end
24
+ end
@@ -17,6 +17,7 @@ class Terminal < ActiveRecord::Base
17
17
  has_many :collections, :order => 'id DESC'
18
18
  has_many :payments, :order => 'id DESC'
19
19
  has_many :terminal_orders, :order => 'id DESC'
20
+ has_many :session_records, :order => 'created_at DESC'
20
21
 
21
22
  list :pings, :marshal => true, :maxlength => 480
22
23
 
@@ -0,0 +1,10 @@
1
+ paginated_collection(terminal.session_records.page(params[:page]).per(15), download_links: false) do
2
+ table_for(collection, :class => 'index_table index', :i18n => SessionRecord) do |t|
3
+ t.column :started_at do |x|
4
+ Time.at(x.started_at).strftime("%d.%m.%Y %H:%M:%S")
5
+ end
6
+ t.column :upstream
7
+ t.column :downstream
8
+ t.column :time
9
+ end
10
+ end
@@ -660,4 +660,9 @@ ru:
660
660
  item_type: Тип сущности
661
661
  item_id: ID сущности
662
662
  event: Действие
663
- user: Пользователь
663
+ user: Пользователь
664
+ session_record:
665
+ started_at: Время начала
666
+ upstream: Передано байт
667
+ downstream: Принято байт
668
+ time: Время соединения, секунд
@@ -78,6 +78,8 @@ ru:
78
78
  upgrade: Обновление терминалов
79
79
  all_pings: Полная история связи
80
80
  pings: История связи
81
+ all_session_records: Все сессии
82
+ session_records: Сессии
81
83
  terminal_build:
82
84
  gems_ready: Готова к деплою
83
85
  gems_not_ready: Подготавливается
@@ -51,4 +51,6 @@ Rails.application.class.routes.draw do
51
51
  post :pay
52
52
  end
53
53
  end
54
+
55
+ resources :session_records
54
56
  end
@@ -0,0 +1,5 @@
1
+ class AddLastSessionStartedAtToTerminals < ActiveRecord::Migration
2
+ def change
3
+ add_column :terminals, :last_session_started_at, :integer, :null => false, :default => 0
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ class CreateSessionRecords < ActiveRecord::Migration
2
+ def change
3
+ create_table :session_records do |t|
4
+ t.belongs_to :terminal
5
+ t.string :message_id
6
+ t.integer :started_at
7
+ t.integer :upstream
8
+ t.integer :downstream
9
+ t.integer :time
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :session_records, [ :terminal_id, :message_id ], :unique => true
15
+ add_index :session_records, :created_at
16
+ end
17
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20130108091644) do
14
+ ActiveRecord::Schema.define(:version => 20130217113740) do
15
15
 
16
16
  create_table "active_admin_comments", :force => true do |t|
17
17
  t.string "resource_id", :null => false
@@ -350,6 +350,20 @@ ActiveRecord::Schema.define(:version => 20130108091644) do
350
350
  t.datetime "updated_at", :null => false
351
351
  end
352
352
 
353
+ create_table "session_records", :force => true do |t|
354
+ t.integer "terminal_id"
355
+ t.string "message_id"
356
+ t.integer "started_at"
357
+ t.integer "upstream"
358
+ t.integer "downstream"
359
+ t.integer "time"
360
+ t.datetime "created_at", :null => false
361
+ t.datetime "updated_at", :null => false
362
+ end
363
+
364
+ add_index "session_records", ["created_at"], :name => "index_session_records_on_created_at"
365
+ add_index "session_records", ["terminal_id", "message_id"], :name => "index_session_records_on_terminal_id_and_message_id", :unique => true
366
+
353
367
  create_table "system_receipt_templates", :force => true do |t|
354
368
  t.string "keyword"
355
369
  t.text "template"
@@ -444,6 +458,9 @@ ActiveRecord::Schema.define(:version => 20130108091644) do
444
458
  t.integer "incomplete_orders_count", :default => 0, :null => false
445
459
  t.datetime "created_at", :null => false
446
460
  t.datetime "updated_at", :null => false
461
+ t.integer "card_reader_error"
462
+ t.integer "watchdog_error"
463
+ t.integer "last_session_started_at", :default => 0, :null => false
447
464
  end
448
465
 
449
466
  add_index "terminals", ["agent_id"], :name => "index_terminals_on_agent_id"
@@ -1,5 +1,5 @@
1
1
  module Smartkiosk
2
2
  module Server
3
- VERSION = '0.10.14'
3
+ VERSION = '0.10.15'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartkiosk-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.14
4
+ version: 0.10.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -113,6 +113,7 @@ files:
113
113
  - app/controllers/application_controller.rb
114
114
  - app/controllers/collections_controller.rb
115
115
  - app/controllers/payments_controller.rb
116
+ - app/controllers/session_records_controller.rb
116
117
  - app/controllers/system_receipt_templates_controller.rb
117
118
  - app/controllers/terminal_builds_controller.rb
118
119
  - app/controllers/terminal_orders_controller.rb
@@ -148,6 +149,7 @@ files:
148
149
  - app/models/report_template.rb
149
150
  - app/models/revision.rb
150
151
  - app/models/role.rb
152
+ - app/models/session_record.rb
151
153
  - app/models/system_receipt_template.rb
152
154
  - app/models/terminal.rb
153
155
  - app/models/terminal_build.rb
@@ -171,6 +173,7 @@ files:
171
173
  - app/views/admin/terminal_profiles/_tree.html.haml
172
174
  - app/views/admin/terminal_profiles/sort.html.haml
173
175
  - app/views/admin/terminals/pings.html.arb
176
+ - app/views/admin/terminals/session_records.html.arb
174
177
  - app/views/admin/terminals/upgrade_build.html.arb
175
178
  - app/views/layouts/application.html.erb
176
179
  - app/views/welcome/index.html.erb
@@ -252,6 +255,8 @@ files:
252
255
  - db/migrate/20130104090957_create_terminal_profile_provider_groups.rb
253
256
  - db/migrate/20130108091644_create_terminal_profile_promotions.rb
254
257
  - db/migrate/20130216173828_add_watchdog_and_card_reader_errors_to_terminals.rb
258
+ - db/migrate/20130217113617_add_last_session_started_at_to_terminals.rb
259
+ - db/migrate/20130217113740_create_session_records.rb
255
260
  - db/schema.rb
256
261
  - db/seeds.rb
257
262
  - db/seeds/receipt_templates/payment.txt
@@ -323,7 +328,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
323
328
  version: '0'
324
329
  segments:
325
330
  - 0
326
- hash: 3902194901356889278
331
+ hash: -211246162211189659
327
332
  required_rubygems_version: !ruby/object:Gem::Requirement
328
333
  none: false
329
334
  requirements:
@@ -332,10 +337,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
337
  version: '0'
333
338
  segments:
334
339
  - 0
335
- hash: 3902194901356889278
340
+ hash: -211246162211189659
336
341
  requirements: []
337
342
  rubyforge_project:
338
- rubygems_version: 1.8.23
343
+ rubygems_version: 1.8.24
339
344
  signing_key:
340
345
  specification_version: 3
341
346
  summary: Smartkiosk server application