iron_warbler 2.0.7.9 → 2.0.7.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: 179360dc9b7500f3725379c3c25e6a43c0f5b4bcf4fff1d16f1b23022fe1e8dc
4
- data.tar.gz: e0800a507ec076cb0f819838c83a01d4ba75130b81fd4c86fe1e2fa1acdc905c
3
+ metadata.gz: 64fed34a3ac20ee17e2f5ff71388651aa4c50fb5af4d52de55e498fbcbe0909c
4
+ data.tar.gz: 6acd4df6ce71f9952024d38cb93199994d9565eead600d4e21dc6f21398c4386
5
5
  SHA512:
6
- metadata.gz: '08052f61264a239d4e07bc14564e1f54c624d627c947f1ab7cce88a7e6ddffeaac64d92d91393c8f8842e0d7c8db236f1b0ec589a9b3e9251a00dd17a0f7232e'
7
- data.tar.gz: 29772fd02c33118fb73797a981a4b03d0bbe561ab645623c4fd5abb0dc7fa0f2a6e9c7fd1bcb5cd918c873751d05210574ff38281e1ebfa72656357970dcb468
6
+ metadata.gz: f11db74c6f01dba9a52e32677df8d8ea00722cc33fa2be8ee5156bc1725b5c78255cd3bc882b7f1957ef7bdf821f9047489113ae7ebc9e64e21e49e228517cbe
7
+ data.tar.gz: a8d75e3d30703ca2007ef4af2160549fbe7f5cdeaf0899748b7d7a5b987a3dda1c0ad2e93005dd7de91aa79c0923ef55a869ec42cb74e365aac6a4cd58dbcb19
@@ -29,10 +29,11 @@ class Iro::AlertsController < Iro::ApplicationController
29
29
  @alert = Iro::Alert.find(params[:id])
30
30
  authorize! :update, @alert
31
31
  if @alert.update params[:alert].permit!
32
- redirect_to action: :index, notice: 'Alert was successfully updated.'
32
+ flash_notice 'ok'
33
33
  else
34
- render :edit
34
+ flash_alert @alert
35
35
  end
36
+ redirect_to action: :index, notice: 'Alert was successfully updated.'
36
37
  end
37
38
 
38
39
  ##
@@ -42,7 +43,8 @@ class Iro::AlertsController < Iro::ApplicationController
42
43
 
43
44
  def set_lists
44
45
  # @profiles_list = Wco::Profile.list
45
- @stocks_list = [[nil,nil]] + Iro::Stock.active.map { |s| [ s.ticker, s.ticker ] }
46
+ @stocks_list = Iro::Stock.list
47
+ puts! @stocks_list, '@stocks_list'
46
48
  end
47
49
 
48
50
 
@@ -3,11 +3,16 @@ class Iro::DatapointsController < Iro::ApplicationController
3
3
 
4
4
  ## params: d, k, v
5
5
  def create
6
+ authorize! :create, Iro::Datapoint
6
7
  begin
7
- Iro::Datapoint.create( k: params[:k], v: params[:v], created_at: params[:time] )
8
+ Iro::Datapoint.create!(
9
+ date: params[:d],
10
+ kind: params[:k],
11
+ value: params[:v],
12
+ )
8
13
  render json: { status: :ok }
9
- rescue ActiveRecord::NotNullViolation => exception
10
- render json: { status: :unauthorized }, status: :unauthorized
14
+ rescue Mongoid::Errors::Validations => e
15
+ render json: { status: 401 }, status: 401
11
16
  end
12
17
  end
13
18
 
@@ -24,8 +29,8 @@ class Iro::DatapointsController < Iro::ApplicationController
24
29
  ORDER BY
25
30
  d.date;"
26
31
 
27
- outs = ActiveRecord::Base.connection.execute(sql)
28
- puts! outs, 'outs'
32
+ # outs = ActiveRecord::Base.connection.execute(sql)
33
+ # puts! outs, 'outs'
29
34
 
30
35
  render json: outs
31
36
 
@@ -14,12 +14,13 @@ class Iro::Alert
14
14
 
15
15
  STATUS_ACTIVE = 'active'
16
16
  STATUS_INACTIVE = 'inactive'
17
- STATUSES = [ 'active', 'inactive' ]
17
+ STATUSES = [ nil, 'active', 'inactive' ]
18
+ field :status, default: STATUS_ACTIVE
18
19
  def self.active
19
20
  where( status: STATUS_ACTIVE )
20
21
  end
21
22
 
22
- field :class_name
23
+ field :class_name, default: 'Iro::Stock'
23
24
  validates :class_name, presence: true
24
25
 
25
26
  field :symbol
@@ -6,8 +6,14 @@ class Iro::Datapoint
6
6
  store_in collection: 'iro_datapoints'
7
7
 
8
8
  field :date
9
+ index({ kind: -1, date: -1 })
10
+
9
11
  field :value, type: Float
12
+ validates :value, presence: true
13
+
10
14
  field :kind
15
+ validates :kind, presence: true
16
+ index({ kind: -1 })
11
17
 
12
18
  def self.test_0trash
13
19
  add_fields = { '$addFields': {
@@ -10,20 +10,21 @@ class Iro::Stock
10
10
  def self.active
11
11
  where( status: STATUS_ACTIVE )
12
12
  end
13
- field :status
13
+ field :status, default: STATUS_ACTIVE
14
14
 
15
15
  field :ticker
16
16
  validates :ticker, uniqueness: true, presence: true
17
+ index({ ticker: -1 }, { unique: true })
17
18
 
18
19
  field :last, type: :float
19
20
 
20
- def self.list
21
- end
22
-
23
- def self.tickers_list
24
- [nil] + all.map( &:ticker )
25
- end
26
21
 
27
22
  # has_many :strategies, class_name: 'Iro::Strategy', inverse_of: :stock
28
23
 
24
+ def to_s
25
+ ticker
26
+ end
27
+ def self.list
28
+ [[nil,nil]] + all.map { |sss| [ sss.ticker, sss.ticker ] }
29
+ end
29
30
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'httparty'
3
3
 
4
- class Tda::Api
4
+ class Tda::Stock
5
5
  include ::HTTParty
6
6
  base_uri 'https://api.tdameritrade.com'
7
7
 
@@ -11,13 +11,14 @@
11
11
  - if alert.new_record?
12
12
  %label New
13
13
  - else
14
- = f.select :status, options_for_select([ 'active', 'inactive' ], selected: alert.status )
14
+ %label Status
15
+ = f.select :status, options_for_select(Iro::Alert::STATUSES, selected: alert.status )
15
16
  -# .field
16
17
  -# %label Notify
17
18
  -# = f.select :profile_id, options_for_select( @profiles_list, selected: alert.profile_id )
18
19
  .field
19
20
  %label When
20
- = f.select :class_name, options_for_select([ nil, 'Iro::Stock', 'Iro::Option' ])
21
+ = f.select :class_name, options_for_select([ nil, 'Iro::Stock', 'Iro::Option' ], selected: alert.class_name )
21
22
  -# .field
22
23
  -# = f.label :kind
23
24
  -# = f.text_field :kind
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7.9
4
+ version: 2.0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: business_time
@@ -217,7 +217,7 @@ files:
217
217
  - app/controllers/iro/stocks_controller.rb
218
218
  - app/controllers/iro/strategies_controller.rb
219
219
  - app/helpers/iro/application_helper.rb
220
- - app/jobs/iro/application_job.rb
220
+ - app/jobs/iro/application_job.rb-trash
221
221
  - app/mailers/iro/alert_mailer.rb
222
222
  - app/mailers/iro/application_mailer.rb
223
223
  - app/models/iro/alert.rb