ish_models 0.0.33.87 → 0.0.33.94

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: 5d00e6d3fc00fb69a6e14b26fc9cd98bceb35cd4f9ff264237b7559cb2c2c2f8
4
- data.tar.gz: 0a17595a91d780e7ce4720cf5c6f667d0e6fc82a02897a75a73f4e49f51ed089
3
+ metadata.gz: 70debd7a9ae9d44c72b135dc07c1d2e72f01d7381c154a68ad47b72600e3f5b7
4
+ data.tar.gz: c8361dce103b2f3ac55e3aeb440ed967048e40d17e1e495f4b80b4d2c9918885
5
5
  SHA512:
6
- metadata.gz: d18e848135a1f80021438470ed16cc07cc8ab16774d2a71f7c47e191dd131274f4a840f295614708435ad4e0737c87c6d8634c02f7b43832c0dca6ce30471a8f
7
- data.tar.gz: a4198f99401015bf8840b5df893768fd59e518d4af9fbc6303daf90bd54e013da63b3f30d470d74b3e849c989975c58bd0e3dcf22feac7d1eeff339c65614980
6
+ metadata.gz: 1b0a2d11b62f6841bf034113917f75cca41814cd716205394dc3223ae82134d24bcf59ed9a3f8945a8f520dc58877523a21dbfb56e350bcc8432fce1927de61e
7
+ data.tar.gz: 90affd7f361d3b63f4b6c4711132614032788d0d41c09551542a0fa467bbe08ee522911c9d68b1ed5521934eba88d27706cb228dce3afcf95a0853fd9c21ebab
@@ -0,0 +1,29 @@
1
+
2
+ class Stockwatcher
3
+
4
+ def initialize
5
+ end
6
+
7
+ # every minute, for alphavantage.co
8
+ def watch
9
+ stocks = Ish::StockWatch.where( :notification_type => :EMAIL )
10
+ puts! stocks.map(&:ticker), "Watching these stocks:"
11
+ stocks.each do |stock|
12
+ r = HTTParty.get "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=#{stock.ticker}&interval=1min&apikey=X1C5GGH5MZSXMF3O", timeout: 10
13
+ r2 = JSON.parse( r.body )['Time Series (1min)']
14
+ r3 = r2[r2.keys.first]['4. close'].to_f
15
+ if stock.direction == :ABOVE && r3 >= stock.price ||
16
+ stock.direction == :BELOW && r3 <= stock.price
17
+ IshManager::ApplicationMailer.stock_alert( stock ).deliver
18
+
19
+ ## actions
20
+ ## exit the position
21
+ # stock.stock_actions.where( :is_active => true ).each do |action|
22
+ # # @TODO: actions
23
+ # end
24
+
25
+ end
26
+ end
27
+ end
28
+
29
+ end
data/lib/ish_models.rb CHANGED
@@ -32,6 +32,7 @@ require 'ish/payment.rb'
32
32
  require 'ish/stock_action.rb'
33
33
  require 'ish/stock_option.rb'
34
34
  require 'ish/stock_watch.rb'
35
+ require 'ish/stockwatcher.rb'
35
36
  require 'ish/invoice.rb'
36
37
  require 'ish/lead.rb'
37
38
  require 'ish/campaign.rb'
@@ -1,4 +1,8 @@
1
1
 
2
+ #
3
+ # See also ish_manager / lib / stockwatcher.rb
4
+ #
5
+
2
6
  class IshModels::StockWatch
3
7
  include Mongoid::Document
4
8
  include Mongoid::Timestamps
@@ -11,6 +15,7 @@ class IshModels::StockWatch
11
15
  NOTIFICATION_SMS = :SMS
12
16
  ACTIONS = NOTIFICATION_TYPES
13
17
  field :notification_type, :type => Symbol, :as => :action
18
+
14
19
  =begin
15
20
  def action
16
21
  return notification_type
data/lib/video.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Video
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
+ include Mongoid::Paperclip
4
5
 
5
6
  PER_PAGE = 6
6
7
 
@@ -20,7 +21,7 @@ class Video
20
21
  field :lang, :type => String, :default => 'en'
21
22
 
22
23
  field :youtube_id, :type => String
23
- validates :youtube_id, :uniqueness => true, :presence => true
24
+ # validates :youtube_id, :uniqueness => true, :presence => true
24
25
 
25
26
  belongs_to :tag, :optional => true
26
27
  belongs_to :city, :optional => true
@@ -32,7 +33,7 @@ class Video
32
33
  accepts_nested_attributes_for :site, :tag, :city
33
34
 
34
35
  def self.list
35
- [['', nil]] + Video.all.order_by( :created_at => :desc ).map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
36
+ [['', nil]] + Video.unscoped.order_by( :created_at => :desc ).map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
36
37
  end
37
38
 
38
39
  set_callback( :create, :before ) do |doc|
@@ -45,9 +46,28 @@ class Video
45
46
 
46
47
  field :issue
47
48
 
48
- has_attached_file :video, styles: {
49
- :thumb => { geometry: '192x108', format: 'jpeg' },
50
- }, processors: [ :transcoder ]
49
+ has_mongoid_attached_file :video,
50
+ # styles: { :thumb => { geometry: '192x108', format: 'jpeg' }, },
51
+ # processors: [ :transcoder ],
52
+ :storage => :s3,
53
+ :s3_credentials => ::S3_CREDENTIALS,
54
+ :path => "videos/:style/:id/:filename",
55
+ :s3_protocol => 'https',
56
+ :s3_permissions => 'public-read',
57
+ :validate_media_type => false
51
58
  validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
52
59
 
60
+ has_mongoid_attached_file :thumb,
61
+ :styles => {
62
+ :mini => '20x20#',
63
+ :thumb => "100x100#",
64
+ :small => "400x400>",
65
+ },
66
+ :storage => :s3,
67
+ :s3_credentials => ::S3_CREDENTIALS,
68
+ :path => "videos/:style/:id/thumb_:filename",
69
+ :s3_protocol => 'https',
70
+ :validate_media_type => false
71
+ validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
72
+
53
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.87
4
+ version: 0.0.33.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -14,20 +14,20 @@ dependencies:
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 6.1.0
20
- - - ">="
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 6.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 6.1.0
30
- - - ">="
30
+ - - "~>"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 6.1.0
33
33
  - !ruby/object:Gem::Dependency
@@ -131,6 +131,7 @@ files:
131
131
  - lib/ish/stock_action.rb
132
132
  - lib/ish/stock_option.rb
133
133
  - lib/ish/stock_watch.rb
134
+ - lib/ish/stockwatcher.rb
134
135
  - lib/ish_models.rb
135
136
  - lib/ish_models/cache_key.rb
136
137
  - lib/ish_models/configuration.rb
@@ -165,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0'
167
168
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.7.3
169
+ rubygems_version: 3.0.6
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: models of ish