ish_models 0.0.33.104 → 0.0.33.105

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: c54bda7472ded08d0e07e851a7479ffe905be79a5e3b408d4c461cba9731a0b3
4
- data.tar.gz: 2a29fc4105594f11a10ef13b62244f28bf231a4756a0cbf2ba1b562aac9bdc5c
3
+ metadata.gz: 1a5ee54bb9e2f64ca4e1e475735b76cb24ef400a760137c9bd7a6725a297f970
4
+ data.tar.gz: 93d9073dc10a680aaacb038577f2116894313bf196e27df0f11c2ca5ccf3c4a7
5
5
  SHA512:
6
- metadata.gz: 3873702c519b09a26929ebad21922dfa1d431663a7a56b7b7912edb889652ca97e0850a680943555312291dce405aa69b09f6855f808aea98c540424890eaa9e
7
- data.tar.gz: c9ece62b2a99f31681cf9830cc1b2ac28caa8a88ae79ee59744134c852bfbdff76ee1d6cc65e25d0539ed37dc8c04e94248f663f5cf32783d103c9f685de96b8
6
+ metadata.gz: b5c035fd46a34780d8965419cf873abb305e40d13ebda9bf27eca5da7a7420b554fbf1d4a248c2230e02b55d05e0a5cb09cddef3b22a6709809d13033b0a7125
7
+ data.tar.gz: d11beea10ec8efa44ec3eeb7e9f74236fa9bce648f7572728f045687d8c8d9997d7a7bc3d89bd8a4e21c582336e56bc07a7febe4831b1fc14320cb67076fefc7
data/lib/city.rb CHANGED
@@ -3,28 +3,18 @@ class City
3
3
  include ::Mongoid::Timestamps
4
4
 
5
5
  field :name, :type => String
6
-
7
6
  field :description, :type => String, :default => 'The description of this city'
8
7
 
9
8
  field :cityname, :type => String
10
9
  validates :cityname, :uniqueness => true, :allow_nil => false, :presence => true
11
-
12
- field :name_en, :type => String, :default => ''
13
- # validates :name_en, :uniqueness => true, :allow_nil => false, :presence => true
14
-
15
- field :name_ru, :type => String, :default => ''
16
- # validates :name_ru, :uniqueness => true, :allow_nil => false, :presence => true
17
-
18
- field :name_pt, :type => String, :default => ''
19
- # validates :name_pt, :uniqueness => true, :allow_nil => false, :presence => true
20
-
21
- field :is_feature, :type => Boolean, :default => false
22
-
10
+ def slug; cityname; end
11
+ def slug= s; cityname = s; end
12
+
23
13
  field :x, :type => Float
24
14
  field :y, :type => Float
25
-
15
+
26
16
  belongs_to :country, :optional => true
27
-
17
+
28
18
  has_many :events
29
19
  has_many :galleries
30
20
  has_many :photos
@@ -32,32 +22,20 @@ class City
32
22
  has_many :venues
33
23
  has_many :videos
34
24
  has_many :tags
25
+
35
26
  has_many :current_users, :class_name => '::IshModels::UserProfile', :inverse_of => :current_city
27
+ has_many :newsitems
36
28
 
29
+ has_many :current_users, :class_name => '::IshModels::UserProfile', :inverse_of => :current_city
37
30
  has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
38
31
  has_one :guide, :class_name => '::IshModels::UserProfile', :inverse_of => :guide_city
39
32
 
40
- has_many :newsitems
41
-
42
- # @TODO @deprecated, I wish I don't use it.
43
- field :n_newsitems, :type => Integer, :default => 16
44
-
45
33
  embeds_many :features
46
- # @TODO @deprecated, I wish I don't use it.
47
- field :n_features, :type => Integer, :default => 4
48
34
 
49
35
  field :calendar_frame, :type => String
50
-
36
+
51
37
  default_scope ->{ order_by({ :name => :asc }) }
52
38
 
53
- def self.feature
54
- where( :is_feature => true )
55
- end
56
-
57
- def self.non_feature
58
- where( :is_feature => false )
59
- end
60
-
61
39
  def self.list
62
40
  out = self.order_by( :name => :asc )
63
41
  # no_city = City.where( :cityname => 'no_city' ).first || City.create( :cityname => 'no_city', :name => 'No City' )
@@ -81,10 +59,8 @@ class City
81
59
 
82
60
  def j_reports args = {}
83
61
  out = []
84
- self.reports.each do |r| # .page( params[:reports_page]
62
+ self.reports.each do |r|
85
63
  rr = r.clone
86
- # rr[:photo_url] = r.photo.photo.url( :mini ) unless r.photo.blank?
87
- # rr[:photo_url] ||= '/assets/missing.png'
88
64
  rr[:username] = r.user.username
89
65
  rr.created_at = r.created_at # pretty_date( r.created_at )
90
66
  rr[:tag_name] = r.tag.name unless r.tag.blank?
@@ -102,23 +78,12 @@ class City
102
78
  return cities
103
79
  end
104
80
 
105
- def self.feature
106
- City.where( :is_feature => true )
107
- end
108
-
109
- def add_newsitem doc
110
- # puts! self.newsitems, "city newsitems are"
111
- if 'Video' == doc.class.name
112
- self.newsitems << Newsitem.new({ :descr => '', :username => '', :video => doc })
113
- end
114
- end
115
-
116
81
  def self.method_missing name, *args, &block
117
82
  city = City.where( :cityname => name ).first
118
83
  return city if city
119
84
  super
120
85
  end
121
-
86
+
122
87
  end
123
88
 
124
89
 
data/lib/gallery.rb CHANGED
@@ -37,6 +37,9 @@ class Gallery
37
37
  field :galleryname, :type => String
38
38
  index({ :galleryname => -1 }, { :unique => true })
39
39
  embeds_many :gallery_names, :class_name => '::Ish::GalleryName'
40
+ def self.find_by_slug slug
41
+ ::Gallery.where( galleryname: slug ).first
42
+ end
40
43
 
41
44
  field :subhead, :type => String
42
45
  field :descr, :type => String, :as => :description
@@ -107,9 +110,7 @@ class Gallery
107
110
  RENDER_TITLES = 'gallery_render_titles_const' # string b/c transmited over http
108
111
  RENDER_THUMBS = 'gallery_render_thumbs_const' # string b/c transmited over http
109
112
 
110
- def self.find_by_slug slug
111
- ::Gallery.where( galleryname: slug ).first
112
- end
113
+ belongs_to :newsparent, polymorphic: true
113
114
 
114
115
  end
115
116
 
@@ -1,5 +1,5 @@
1
1
 
2
- class Stockwatcher
2
+ class AlphavantageStockwatcher
3
3
 
4
4
  def initialize
5
5
  end
@@ -0,0 +1,29 @@
1
+
2
+ class ::YahooStockwatcher
3
+
4
+ # For: https://query1.finance.yahoo.com/v7/finance/chart/qqq?interval=1d&indicators=quote
5
+ def watch_once
6
+
7
+ stocks = Ish::StockWatch.where( :notification_type => :EMAIL )
8
+ puts! stocks.map(&:ticker), "Watching these stocks"
9
+ stocks.each do |stock|
10
+ puts! stock.ticker, 'ticker'
11
+ r = HTTParty.get "https://query1.finance.yahoo.com/v7/finance/chart/#{stock.ticker}?interval=1d&indicators=quote", timeout: 10
12
+ r = JSON.parse( r.body ).deep_symbolize_keys
13
+ r = r[:chart][:result][0][:meta][:regularMarketPrice]
14
+ if stock.direction == :ABOVE && r >= stock.price ||
15
+ stock.direction == :BELOW && r <= stock.price
16
+ IshManager::ApplicationMailer.stock_alert( stock ).deliver
17
+
18
+ ## actions
19
+ ## exit the position
20
+ # stock.stock_actions.where( :is_active => true ).each do |action|
21
+ # # @TODO: actions
22
+ # end
23
+
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
data/lib/ish_models.rb CHANGED
@@ -37,7 +37,8 @@ require 'ish/payment.rb'
37
37
  require 'ish/stock_action.rb'
38
38
  require 'ish/stock_option.rb'
39
39
  require 'ish/stock_watch.rb'
40
- require 'ish/stockwatcher.rb'
40
+ require 'ish/yahoo_stockwatcher.rb'
41
+ # require 'ish/alphavantage_stockwatcher.rb'
41
42
  require 'ish/invoice.rb'
42
43
  require 'ish/lead.rb'
43
44
  require 'ish/campaign.rb'
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.104
4
+ version: 0.0.33.105
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -119,6 +119,7 @@ files:
119
119
  - lib/gameui/map.rb
120
120
  - lib/gameui/marker.rb
121
121
  - lib/gameui/premium_purchase.rb
122
+ - lib/ish/alphavantage_stockwatcher.rb
122
123
  - lib/ish/campaign.rb
123
124
  - lib/ish/crawler.rb
124
125
  - lib/ish/gallery_name.rb
@@ -129,7 +130,7 @@ files:
129
130
  - lib/ish/stock_action.rb
130
131
  - lib/ish/stock_option.rb
131
132
  - lib/ish/stock_watch.rb
132
- - lib/ish/stockwatcher.rb
133
+ - lib/ish/yahoo_stockwatcher.rb
133
134
  - lib/ish_models.rb
134
135
  - lib/ish_models/cache_key.rb
135
136
  - lib/ish_models/configuration.rb