wco_models 3.4.0.9 → 3.5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/wco/main.scss +3 -7
  3. data/app/assets/stylesheets/wco/photos.scss +1 -2
  4. data/app/controllers/wco/api/newspartials_controller.rb +9 -0
  5. data/app/controllers/wco/newsvideos_controller.rb +12 -6
  6. data/app/controllers/wco/office_action_templates_controller.rb +0 -3
  7. data/app/controllers/wco/publishers_controller.rb +16 -6
  8. data/app/controllers/wco/reports_controller.rb +5 -6
  9. data/app/controllers/wco/sites_controller.rb +1 -1
  10. data/app/controllers/wco/tags_controller.rb +1 -1
  11. data/app/models/iro/option.rb +4 -37
  12. data/app/models/iro/priceitem.rb +4 -62
  13. data/app/models/tda/option.rb +41 -39
  14. data/app/models/wco/newspartial.rb +12 -2
  15. data/app/models/wco/publisher.rb +8 -29
  16. data/app/models/wco/report.rb +2 -12
  17. data/app/models/wco/setting.rb +1 -1
  18. data/app/models/wco/site.rb +67 -1
  19. data/app/models/wco/tag.rb +8 -15
  20. data/app/views/wco/api/newsproducer/_studio_blue2.js +16 -37
  21. data/app/views/wco/api/newsproducer/_studio_fps.js +12 -12
  22. data/app/views/wco/api/newsproducer/studio_fps.html.erb +8 -10
  23. data/app/views/wco/api/newsproducer/trash/_scenes.js-bk +20 -0
  24. data/app/views/wco/api/newsproducer/trash/_scenes.js.erb +15 -0
  25. data/app/views/wco/api/newsproducer/trash/_studio_blue0.js +326 -0
  26. data/app/views/wco/api/newsproducer/trash/_studio_blue1.js +733 -0
  27. data/app/views/wco/api/newsproducer/trash/studio_blue0.html.erb +27 -0
  28. data/app/views/wco/api/newsproducer/trash/studio_blue1.html.erb +108 -0
  29. data/app/views/wco/api/newsvideos/show.jbuilder +1 -1
  30. data/app/views/wco/newsvideos/show.haml +2 -2
  31. data/app/views/wco/office_action_templates/index.haml +1 -1
  32. data/app/views/wco/office_actions/_actions.haml +1 -1
  33. data/app/views/wco/publishers/_form.haml +2 -11
  34. data/app/views/wco/publishers/_post_with.haml +1 -1
  35. data/app/views/wco/reports/_form.haml +2 -13
  36. data/app/views/wco/reports/_index.haml +11 -18
  37. data/app/views/wco/reports/show.haml +1 -6
  38. data/app/views/wco/sitemap_paths/check.haml-trash +13 -0
  39. data/app/views/wco/sites/index.haml +0 -6
  40. data/app/views/wco/tags/_form.haml +0 -3
  41. data/config/routes.rb +10 -9
  42. data/lib/shortcuts.rb +1 -1
  43. data/lib/wco_models.rb +1 -1
  44. metadata +28 -22
  45. data/app/views/wco/api/newsproducer/README_newsproducer.txt +0 -12
  46. /data/app/views/wco/api/newsproducer/{_scenes.js-bk → done/_scenes.js-bk} +0 -0
  47. /data/app/views/wco/api/newsproducer/{_scenes.js.erb → done/_scenes.js.erb} +0 -0
  48. /data/app/views/wco/api/newsproducer/{_studio_1.js → done/_studio_1.js} +0 -0
  49. /data/app/views/wco/api/newsproducer/{_studio_blue0.js → done/_studio_blue0.js} +0 -0
  50. /data/app/views/wco/api/newsproducer/{_studio_blue1.js → done/_studio_blue1.js} +0 -0
  51. /data/app/views/wco/api/newsproducer/{_studio_coc.js → done/_studio_coc.js} +0 -0
  52. /data/app/views/wco/api/newsproducer/{_studio_coc.js-bk → done/_studio_coc.js-bk} +0 -0
  53. /data/app/views/wco/api/newsproducer/{_studio_coc.js-cannon → done/_studio_coc.js-cannon} +0 -0
  54. /data/app/views/wco/api/newsproducer/{_studio_ra2.js → done/_studio_ra2.js} +0 -0
  55. /data/app/views/wco/api/newsproducer/{_touch_controls.js → done/_touch_controls.js} +0 -0
  56. /data/app/views/wco/api/newsproducer/{_touch_pad.css → done/_touch_pad.css} +0 -0
  57. /data/app/views/wco/api/newsproducer/{canvas.html.erb → done/canvas.html.erb} +0 -0
  58. /data/app/views/wco/api/newsproducer/{canvas_minimal.html.erb → done/canvas_minimal.html.erb} +0 -0
  59. /data/app/views/wco/api/newsproducer/{games_fps.html → done/games_fps.html} +0 -0
  60. /data/app/views/wco/api/newsproducer/{studio_1.html.erb → done/studio_1.html.erb} +0 -0
  61. /data/app/views/wco/api/newsproducer/{studio_blue0.html.erb → done/studio_blue0.html.erb} +0 -0
  62. /data/app/views/wco/api/newsproducer/{studio_blue1.html.erb → done/studio_blue1.html.erb} +0 -0
  63. /data/app/views/wco/api/newsproducer/{studio_coc.html.erb → done/studio_coc.html.erb} +0 -0
  64. /data/app/views/wco/api/newsproducer/{studio_ra2.html.erb → done/studio_ra2.html.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 931abf0936b81ddba99ba3723e7d3a138009e6dcc735effc1655113d57ebde03
4
- data.tar.gz: 6ae127b731884b1d1c58a017c455158f8b07d23d6ec56ed3afcb70818a7faa9e
3
+ metadata.gz: 98df45a95c0e1f51608e7850bb74dbbfed82fff8ee29f0c51d17b4817b200315
4
+ data.tar.gz: '0168d498f4dc70d1e242a24f2de8d4014b8647f6185516dd17a6ba7db5f90dd4'
5
5
  SHA512:
6
- metadata.gz: ccdadbdf9e7984ace44cf61ee7d6a0568181c55b98201903ff900233476eea4079f2dcadae689408d7494f47338e1bf1a76a9df40cfb546c6cdefec85dc04c6a
7
- data.tar.gz: a9662923a67361ad564cd9512a2617555b657974cd50127365cf0b8c47e3438caa013dba020e4b91cafd7f5d610a9cfa513c4fc865714aa6009847f8b0b1e99a
6
+ metadata.gz: e1f049011d86da86594973c51c4a19be6f6402ff26bc048e51980c442582f3b5760f8450cc11bb1f87df5466cb4d1a975c2c4083883d5bded904229b9f61a1a8
7
+ data.tar.gz: a0eaaf38020951999f33ec4f50a29b3777a1cd4736555780db2db29947e4a790349516c1e835ae9a312a8c2d06a9c9e961a8e3c1b30de8db4e0520be3f91ebf8
@@ -117,10 +117,7 @@ textarea.monospace {
117
117
  /* D */
118
118
 
119
119
  .d-flex {
120
- align-items: baseline; /* 2026-11-12: I dont want this alignment */
121
- }
122
- .no-align {
123
- align-items: unset;
120
+ align-items: baseline;
124
121
  }
125
122
 
126
123
  .descr {
@@ -346,12 +343,11 @@ table thead.sticky {
346
343
  .w-300px {
347
344
  width: 300px;
348
345
  }
346
+
349
347
  .w-400px {
350
348
  width: 400px;
351
349
  }
350
+
352
351
  .w-500px {
353
352
  width: 500px;
354
353
  }
355
- .w-600px {
356
- width: 500px;
357
- }
@@ -10,11 +10,10 @@
10
10
 
11
11
  div.thumb {
12
12
  margin: 0 0.5em 0.5em 0;
13
- flex-shrink: 0;
14
13
  }
15
14
 
16
15
  .photos-thumbs img,
17
- .thumb {
16
+ img.thumb {
18
17
  border: 1px solid red;
19
18
  width: 100px;
20
19
  height: 100px;
@@ -51,6 +51,15 @@ class Wco::Api::NewspartialsController < Wco::ApiController
51
51
  render json: { status: :ok }
52
52
  end
53
53
 
54
+ ## via puppeteer
55
+ def generate_video
56
+ @newspartial = Wco::Newspartial.unscoped.find params[:id]
57
+ authorize! :create, @newspartial
58
+ @newspartial.generate_video
59
+
60
+ render json: { status: :ok }
61
+ end
62
+
54
63
  def show_config
55
64
  @newspartial = Wco::Newspartial.find params[:id]
56
65
  config = JSON.parse @newspartial.speech_json
@@ -118,20 +118,26 @@ class Wco::NewsvideosController < Wco::ApplicationController
118
118
  @newsvideo = Wco::Newsvideo.unscoped.find params[:id]
119
119
  authorize! :edit, @newsvideo
120
120
 
121
- cmd = "cd #{PUPPETEER_ROOT} ; yarn run newsvideo_generate_all_audio #{@newsvideo.id}"
122
- puts "+++ puppeteer cmd:"
123
- puts cmd
124
- out = `#{cmd}`
125
- puts! out, 'out'
121
+ # cmd = "cd #{PUPPETEER_ROOT} ; yarn run newsvideo_generate_all_audio #{@newsvideo.id}"
122
+ # puts "+++ puppeteer cmd:"
123
+ # puts cmd
124
+ # out = `#{cmd}`
125
+ # puts! out, 'out'
126
+
127
+ @newsvideo.newspartials.each do |newspartial|
128
+ newspartial.generate_speech
129
+ print '.'
130
+ end
126
131
 
127
132
  render json: { status: :ok }
128
133
  end
129
134
 
135
+ ## via puppeteer
130
136
  def generate_all_video
131
137
  @newsvideo = Wco::Newsvideo.unscoped.find params[:id]
132
138
  authorize! :edit, @newsvideo
133
139
 
134
- cmd = "cd #{PUPPETEER_ROOT} ; yarn run newsvideo_generate_all_video #{@newsvideo.id}"
140
+ cmd = "cd #{Wco::Setting.get('PUPPETEER_ROOT')} ; NEWSVIDEO_URL=#{api_newsvideo_url(@newsvideo)} yarn run run_newsvideo_1"
135
141
  puts "+++ puppeteer cmd:"
136
142
  puts cmd
137
143
  out = `#{cmd}`
@@ -25,15 +25,12 @@ class Wco::OfficeActionTemplatesController < Wco::ApplicationController
25
25
  def perform
26
26
  @oat = OAT.find params[:id]
27
27
  authorize! :run, @oat
28
-
29
28
  @conversations = WcoEmail::Conversation.find( params[:conversation_ids] ) if params[:conversation_ids].present?
30
-
31
29
  if 'rb' == @oat.action_type
32
30
  out = eval( @oat.action_exe )
33
31
  elsif 'sh' == @oat.action_type
34
32
  out = `#{@oat.action_exe}`
35
33
  end
36
-
37
34
  flash_notice out
38
35
  redirect_to action: :index
39
36
  end
@@ -12,18 +12,28 @@ class Wco::PublishersController < Wco::ApplicationController
12
12
  redirect_to action: 'index'
13
13
  end
14
14
 
15
+ ## this is becoming obsolete - try using do_run_any
16
+ def do_run
17
+ @publisher = Wco::Publisher.find params[:id]
18
+ authorize! :do_run, @publisher
19
+
20
+ @publisher.props = OpenStruct.new( JSON.parse params[:publisher][:props] )
21
+ # @publisher.do_run binding
22
+ @publisher.do_run
23
+
24
+ flash_notice "Probably ok"
25
+
26
+ redirect_to action: 'index'
27
+ end
28
+
15
29
  def do_run_any
16
30
  @publisher = Wco::Publisher.find params[:id]
17
31
  authorize! :do_run, @publisher
18
32
 
19
33
  @publisher.props = OpenStruct.new( JSON.parse params[:props] )
20
- flag = @publisher.do_run
21
- if !flag
22
- flash_alert @publisher.errors
23
- else
24
- flash_notice "#do_run_any Probably ok"
25
- end
34
+ @publisher.do_run
26
35
 
36
+ flash_notice "Probably ok"
27
37
  redirect_to request.referrer || { action: 'index' }
28
38
  end
29
39
 
@@ -5,18 +5,16 @@ class Wco::ReportsController < Wco::ApplicationController
5
5
 
6
6
  def create
7
7
  params[:report][:tag_ids]&.delete ''
8
- img_thumb_params = params[:report][:image_thumb]
9
- params[:report].delete :image_thumb
10
8
 
11
9
  @report = Wco::Report.new params[:report].permit!
12
10
  authorize! :create, @report
13
11
 
14
12
  @report.author = current_profile
15
13
 
16
- if img_thumb_params.present?
17
- @photo = Wco::Photo.new photo: img_thumb_params
18
- @photo.save!
19
- @report.image_thumb = @photo
14
+ if params[:report][:image_thumb]&.[](:image).present?
15
+ thumb = @report.image_thumb || @report.build_image_thumb
16
+ thumb.image = params[:report][:image_thumb_attributes][:image]
17
+ thumb.save
20
18
  end
21
19
 
22
20
  if @report.save
@@ -207,6 +205,7 @@ class Wco::ReportsController < Wco::ApplicationController
207
205
  params[:report][:tag_ids]&.delete ''
208
206
  img_thumb_params = params[:report][:image_thumb]
209
207
  params[:report].delete :image_thumb
208
+ # puts! img_thumb_params, 'img_thumb_params'
210
209
 
211
210
  @report = Wco::Report.unscoped.find params[:id]
212
211
  authorize! :update, @report
@@ -40,7 +40,7 @@ class Wco::SitesController < Wco::ApplicationController
40
40
 
41
41
  def index
42
42
  authorize! :index, Wco::Site
43
- @sites = Wco::Site.all.includes( :tags )
43
+ @sites = Wco::Site.all
44
44
  end
45
45
 
46
46
  def new
@@ -32,7 +32,7 @@ class Wco::TagsController < Wco::ApplicationController
32
32
 
33
33
  def index
34
34
  authorize! :index, Wco::Tag
35
- @tags = Wco::Tag.where( site: nil ).order_by( slug: :asc )
35
+ @tags = Wco::Tag.all.order_by( slug: :asc )
36
36
 
37
37
  tags = Wco::Tag.all.to_a.group_by(&:parent_id)
38
38
  build_tree = lambda do |parent_id|
@@ -8,7 +8,7 @@ class Iro::Option
8
8
  attr_accessor :recompute
9
9
 
10
10
  belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :strategies
11
- field :ticker, type: :string
11
+ def ticker; stock.ticker; end
12
12
 
13
13
  CALL = 'CALL'
14
14
  PUT = 'PUT'
@@ -67,47 +67,14 @@ class Iro::Option
67
67
  return options
68
68
  end
69
69
 
70
- field :symbol, type: :string
71
- validates :symbol, uniqueness: true
72
- index({ symbol: -1 }, { unique: true, name: 'symbol' })
73
- # def symbol
74
- # return self[:symbol] if self[:symbol]
75
- # self[:symbol] = generate_symbol
76
- # end
77
-
78
70
  ## for schwab, eg:
79
71
  ## "COST 260306C01030000"
80
- def generate_symbol
72
+ def symbol
81
73
  p_c_ = put_call == 'PUT' ? 'P' : 'C'
82
74
  strike_ = format("%08d", (strike.to_f * 1000).round)
83
75
  sym = "#{stock.ticker.ljust(6)}#{expires_on.strftime("%y%m%d")}#{p_c_}#{strike_}"
84
76
  end
85
77
 
86
- def self.find_or_create_by_symbol symbol
87
- option = Iro::Option.where( symbol: symbol ).first
88
- return option if option
89
- h = Iro::Option.symbol_to_h symbol
90
- item = Iro::Option.new({
91
- stock: Iro::Stock.find_by( ticker: h[:ticker] ),
92
- ticker: h[:ticker],
93
- put_call: h[:put_call],
94
- strike: h[:strike],
95
- expires_on: h[:expires_on],
96
- symbol: symbol,
97
- })
98
- item.save
99
- return item
100
- end
101
-
102
- ## trash, I can save the symbol every time. 2026-10-04
103
- # def self.find_by_symbol symbol
104
- # option = self.where( symbol: symbol ).first
105
- # return option if option
106
- # h = Iro::Option.symbol_to_h symbol
107
- # Iro::Option.where( h ).first
108
- # end
109
-
110
-
111
78
  =begin
112
79
  symbol = "META 260424P00500000"
113
80
  =end
@@ -116,7 +83,7 @@ class Iro::Option
116
83
  date_str = symbol[6,6]
117
84
  type = symbol[12] == 'P' ? 'PUT' : 'CALL'
118
85
  strike_str = symbol[13,8]
119
- expires_on = Date.strptime(date_str, "%y%m%d").to_s
86
+ expires_on = Date.strptime(date_str, "%y%m%d")
120
87
  strike = strike_str.to_i / 1000.0
121
88
  return {
122
89
  ticker: ticker,
@@ -125,7 +92,7 @@ class Iro::Option
125
92
  expires_on: expires_on,
126
93
  }
127
94
  end
128
- def to_h
95
+ def symbol_to_h
129
96
  self.class.symbol_to_h symbol
130
97
  end
131
98
 
@@ -21,19 +21,18 @@ class Iro::Priceitem
21
21
  field :bidSize, type: Integer
22
22
  field :ask, type: Float
23
23
  field :askSize, type: Integer
24
- field :last, type: Float ## this is important?
25
- field :mark, type: Float ## no, this is important. (bid+ask)/2
24
+ field :last, type: Float ## this is important
26
25
 
27
26
  field :openPrice, type: Float
28
27
  field :lowPrice, type: Float
29
28
  field :highPrice, type: Float
30
29
  field :closePrice, type: Float
31
30
 
32
- field :quote_at, type: DateTime ## this is important?
31
+ field :quote_at, type: DateTime ## this is important, the timestamp mostly used for analysis
33
32
  field :quoteTimeInLong, type: Integer
34
- field :timestamp, type: Integer ## do not use?
33
+ field :timestamp, type: Integer ## do not use?!
35
34
  field :totalVolume, type: Integer
36
-
35
+ field :mark, type: Float
37
36
  field :exchangeName, type: String
38
37
  field :volatility, type: Float
39
38
 
@@ -44,63 +43,6 @@ class Iro::Priceitem
44
43
  field :openInterest, type: Integer
45
44
  field :strikePrice, type: Float
46
45
 
47
- def self.create_from_chains!
48
- Iro::Iro.schwab_exec_sync ## should be schwab_data_sync()
49
-
50
- stocks = Iro::Stock.active
51
- fridays = 3.times.map { |i| ( Date.current.next_occurring(:friday) + i.weeks ).to_s }
52
-
53
- stocks.each do |stock|
54
- puts "+++ Getting #{stock.ticker}..."
55
- response = Tda::Option.get_chains({
56
- ticker: stock.ticker,
57
- fromDate: fridays[0],
58
- toDate: fridays.last,
59
- strikeCount: 10,
60
- })
61
- # puts! response.keys, 'response.keys'
62
- # puts! response['symbol'], 'response symbol'
63
- # sleep 10
64
-
65
- first_val = nil
66
- ['callExpDateMap', 'putExpDateMap'].each do |which_map|
67
-
68
- response[which_map].each do |_date, strikes|
69
- if fridays.include?( _date.split(':')[0] )
70
- strikes.each do |_strike, vals|
71
- vals.each do |val|
72
- if !first_val
73
- first_val = val
74
- puts! val.keys, 'val keys'
75
- end
76
-
77
- option = Iro::Option.find_or_create_by_symbol( val['symbol'] )
78
-
79
- # opt = OpenStruct.new val
80
- pi = Iro::Priceitem.new( val.slice( 'expirationDate',
81
- 'putCall', 'symbol', 'exchangeName', 'bid', 'ask',
82
- 'last', 'mark', 'bidSize', 'askSize', 'totalVolume', 'quoteTimeInLong', 'volatility',
83
- 'delta', 'gamma', 'theta', 'openInterest', 'strikePrice' ) )
84
- pi.stock = stock
85
- pi.option = option
86
- pi.quote_at = Time.at( val['quoteTimeInLong'] / 1000 )
87
- pi.ticker = stock.ticker
88
- pi.save!
89
-
90
- # puts! pi
91
- print '.'
92
-
93
-
94
- end
95
- end
96
- end ## end fridays.include?
97
- end
98
-
99
- end ## which_map
100
- end
101
-
102
- end
103
-
104
46
  def self.my_find props={}
105
47
  lookup = { '$lookup': {
106
48
  'from': 'iro_price_items',
@@ -1,7 +1,16 @@
1
1
 
2
2
  require 'httparty'
3
3
 
4
+ =begin
5
+ class Schwab
6
+ include HTTParty
7
+ debug_output $stdout
8
+ base_uri 'https://api.schwabapi.com/marketdata/v1'
9
+ end
10
+ =end
11
+
4
12
  class Tda::Option
13
+
5
14
  include ::HTTParty
6
15
  # debug_output $stdout
7
16
  base_uri 'https://api.schwabapi.com/marketdata/v1'
@@ -9,7 +18,7 @@ class Tda::Option
9
18
 
10
19
  ##
11
20
  ## Get entire chains for a ticker
12
- ## params: { ticker, force, strikeCount, fromDate (yyyy-mm-dd), toDate }
21
+ ## params: { ticker, force }
13
22
  ##
14
23
  ## 2024-08-09 :: Continue
15
24
  ## 2024-08-21 :: Continue : )
@@ -20,10 +29,7 @@ class Tda::Option
20
29
  return JSON.parse File.read filename
21
30
 
22
31
  else
23
- query = { symbol: params[:ticker] } ## says query[:symbol], not ticker.
24
- query[:strikeCount] = params[:strikeCount] if params[:strikeCount]
25
- query[:fromDate] = params[:fromDate] if params[:fromDate]
26
- query[:toDate] = params[:toDate] if params[:toDate]
32
+ query = { symbol: params[:ticker] } ## use 'GME' as symbol here even though a symbol is eg 'GME_021023P2.5'
27
33
  # puts! query, 'query'
28
34
 
29
35
  headers = {
@@ -31,30 +37,40 @@ class Tda::Option
31
37
  Authorization: "Bearer #{Iro::Iro.schwab_data_token}",
32
38
  }
33
39
  path = "/chains"
34
- response = self.get path, { headers: headers, query: query }
35
- timestamp = DateTime.parse response.headers['date']
36
- response = response.parsed_response
37
- puts! response, '/chains got this response'
40
+ out = self.get path, {
41
+ headers: headers,
42
+ query: query }
43
+ timestamp = DateTime.parse out.headers['date']
44
+ out = out.parsed_response
45
+ # puts! out, 'outs'
38
46
 
39
47
  outs = []
40
48
  %w| put call |.each do |contractType|
41
- _out = response["#{contractType}ExpDateMap"]
42
- _out.each do |_date, vs| ## date="2023-02-10:5"
49
+ _out = out["#{contractType}ExpDateMap"]
50
+ _out.each do |date, vs| ## date="2023-02-10:5"
43
51
  vs.each do |strike, _v| ## strike="18.5"
44
52
  _v = _v[0] ## weird, keep
45
53
  # puts! _v, '_v'
46
54
 
47
- v = _v.slice( 'putCall', 'symbol', 'bid', 'ask', 'last', 'mark', 'totalVolume', 'openInterest',
48
- 'strikePrice', 'expirationDate' )
55
+ v = {
56
+ putCall: _v['putCall'],
57
+ symbol: _v['symbol'],
58
+ bid: _v['bid'],
59
+ ask: _v['ask'],
60
+ last: _v['last'],
61
+ totalVolume: _v['totalVolume'],
62
+ openInterest: _v['openInterest'],
63
+ strikePrice: _v['strikePrice'],
64
+ expirationDate: _v['expirationDate'],
65
+ }
49
66
  v.each do |k, i|
50
67
  if i == 'NaN'
51
68
  v[k] = nil
52
69
  end
53
70
  end
54
71
 
55
- v[:timestamp] = timestamp # _v['quoteTimeInLong']/1000.0
56
- v[:quote_at] = Time.at(_v['quoteTimeInLong'] / 1000.0)
57
- v[:ticker] = params[:ticker]
72
+ v[:timestamp] = timestamp
73
+ v[:ticker] = params[:ticker]
58
74
  outs.push( v )
59
75
  end
60
76
  end
@@ -67,8 +83,8 @@ class Tda::Option
67
83
  end
68
84
  end
69
85
 
70
- File.write filename, JSON.pretty_generate(response)
71
- return response
86
+ File.write filename, out.to_json
87
+ return out
72
88
  end
73
89
  end
74
90
 
@@ -80,8 +96,6 @@ class Tda::Option
80
96
  OpenStruct.new ::Tda::Option.get_quotes(params)[0]
81
97
  end
82
98
 
83
- ## ...for a single symbol.
84
- ## but use get_quotes_h instead?!
85
99
  ##
86
100
  ## params: contractType, strike, expirationDate, ticker
87
101
  ##
@@ -236,23 +250,19 @@ class Tda::Option
236
250
  end
237
251
 
238
252
  def self.close_credit_call
239
- throw 'r40 - not implemented'
240
253
  end
241
254
  def self.close_long_debit_call_spread
242
- throw 'r41 - not implemented'
243
255
  end
244
256
  def self.close_short_debit_put_spread
245
- throw 'r42 - not implemented'
246
257
  end
247
258
 
248
- ## trash? remove.
249
- # def self.get_token
250
- # opts = {
251
- # grant_type: 'authorization_code',
252
- # access_type: 'offline',
253
- # code: ::TD_AMERITRADE[:code],
254
- # }
255
- # end
259
+ def self.get_token
260
+ opts = {
261
+ grant_type: 'authorization_code',
262
+ access_type: 'offline',
263
+ code: ::TD_AMERITRADE[:code],
264
+ }
265
+ end
256
266
 
257
267
  def self.create_credit_call outer:, inner:, q:, price:
258
268
  query = {
@@ -297,21 +307,13 @@ class Tda::Option
297
307
  # puts! out, 'created credit call?'
298
308
  end
299
309
  def self.create_long_debit_call_spread
300
- throw 'r43 - not implemented'
301
310
  end
302
311
  def self.create_short_debit_put_spread
303
- throw 'r44 - not implemented'
304
312
  end
305
313
 
306
314
 
307
315
  end
308
316
 
309
-
310
-
311
-
312
-
313
-
314
-
315
317
  ##
316
318
  ## From: https://developer.tdameritrade.com/content/place-order-samples
317
319
  ## Buy Limit: Vertical Call Spread
@@ -16,7 +16,7 @@ class Wco::Newspartial
16
16
  field :config_json, type: :string, default: '{}'
17
17
  field :speech_json, type: :string, default: '{}' # the smaller config, excludes audio wav
18
18
 
19
- field :voice, type: :string ## 'af_jessica', 'am_fenrir'
19
+ field :voice, type: :string, default: 'af_jessica' ## 'af_jessica', 'am_fenrir'
20
20
 
21
21
  belongs_to :newsvideo
22
22
 
@@ -112,7 +112,7 @@ class Wco::Newspartial
112
112
  ## uses ishlib3js v0.0.2, not 0.1.0!!!
113
113
  ## @deprecated, this is being brought into wco_models
114
114
  ##
115
- def generate_video
115
+ def generate_video_bk
116
116
  cmd = "cd #{Wco::Setting.get('ISHLIB3JS_ROOT')} ;
117
117
  node ./src/talking_head/example_puppeteer_wired.js \
118
118
  --api_key=#{Wco::Setting.get('WASYACO_SIMPLE_API_KEY')} \
@@ -132,6 +132,16 @@ class Wco::Newspartial
132
132
  puts! out, 'out'
133
133
  return out
134
134
  end
135
+ def generate_video
136
+ out = `#{generate_video_cmd}`
137
+ puts! out, 'out'
138
+ end
139
+ def generate_video_cmd
140
+ cmd = "cd #{Wco::Setting.get('PUPPETEER_ROOT')} ; NEWSPARTIAL_URL=#{api_newspartial_url(@newsvideo)} yarn run run_newspartial_1"
141
+ puts "+++ puppeteer cmd:"
142
+ puts cmd
143
+ cmd
144
+ end
135
145
 
136
146
  def video
137
147
  Wco::Video.where( newspartial_id: self[:id] ).first
@@ -1,11 +1,4 @@
1
1
 
2
- def url_exists?(url)
3
- response = HTTParty.head(url, timeout: 5, follow_redirects: true)
4
- response.code == 200
5
- rescue StandardError
6
- false
7
- end
8
-
9
2
  class Wco::Publisher
10
3
  include Mongoid::Document
11
4
  include Mongoid::Timestamps
@@ -26,35 +19,26 @@ class Wco::Publisher
26
19
  field :post_path
27
20
 
28
21
  has_many :oats, class_name: 'Wco::OfficeActionTemplate'
29
- has_and_belongs_to_many :tags
30
22
 
31
23
  attr_accessor :props
32
24
 
33
25
  def do_run
34
- @publisher = publisher = self
35
-
36
- @site = publisher.site
26
+ @site = site
37
27
  @headers = {}
38
28
  @ctx = OpenStruct.new
39
29
 
40
- puts! publisher.context_eval, 'context_eval'
41
- eval( publisher.context_eval )
42
- puts! @ctx, '@ctx'
30
+ # puts! context_eval, 'context_eval'
31
+ eval( context_eval )
32
+ # puts! @ctx, '@ctx'
43
33
 
44
- if @abort
45
- errors.add(:base, 'aborted')
46
- return false
47
- end
48
-
49
- tmpl = ERB.new publisher.post_body_tmpl
34
+ tmpl = ERB.new post_body_tmpl
50
35
  body = JSON.parse tmpl.result(binding)
51
- puts! body, 'body'
36
+ # puts! body, 'body'
52
37
 
53
38
  out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
54
39
  body: body.to_json,
55
40
  headers: @headers,
56
41
  basic_auth: { username: @site.username, password: @site.password },
57
- debug_output: $stdout,
58
42
  })
59
43
  puts! out.response, 'publisher httparty response'
60
44
  puts! out.body, 'publisher httparty body'
@@ -70,17 +54,12 @@ class Wco::Publisher
70
54
  raise out.body
71
55
  end
72
56
 
73
- if after_eval.present?
74
- puts! after_eval, 'after_eval'
75
- eval( after_eval )
76
- end
77
-
78
- return true
57
+ eval( after_eval ) if after_eval.present?
79
58
  end
80
59
 
81
60
 
82
61
  def to_s
83
- "#{site} :: #{slug}"
62
+ "#{slug}: #{kind} => #{site}"
84
63
  end
85
64
 
86
65
  def self.list
@@ -25,24 +25,14 @@ class Wco::Report
25
25
 
26
26
  field :body
27
27
  def body_json
28
- out = body
29
- if FORMAT_PLAINTEXT == body_format
30
- out = out.gsub(/\r/, '').gsub(/\n\n+/, '<br /><br />')
31
- end
32
- out.to_json
28
+ body.gsub(/\r/, '').gsub(/\n\n+/, '<br /><br />').to_json
33
29
  end
34
- FORMAT_PLAINTEXT = 'format-plaintext'
35
- FORMAT_FULLHTML = 'format-fullhtml'
36
- FORMATS = [ FORMAT_PLAINTEXT, FORMAT_FULLHTML ]
37
- field :body_format, type: :string, default: FORMAT_PLAINTEXT
38
30
 
39
31
  field :x, :type => Float
40
32
  field :y, :type => Float
41
33
  field :z, :type => Float
42
- field :source_url, type: :string
43
- field :summary, type: :string
44
34
 
45
- belongs_to :author, class_name: 'Wco::Profile', optional: true
35
+ belongs_to :author, class_name: 'Wco::Profile'
46
36
 
47
37
  has_one :image_thumb, class_name: 'Wco::Photo', inverse_of: :report, dependent: :destroy
48
38
  accepts_nested_attributes_for :image_thumb
@@ -5,7 +5,7 @@ class Wco::Setting
5
5
  store_in collection: 'wco_settings'
6
6
 
7
7
  KEYS = [ 'HEAD_TTS_ORIGIN', 'ISHLIB3JS_ROOT',
8
- 'OPENAI_API_KEY', 'PEXELS_API_KEY',
8
+ 'OPENAI_API_KEY', 'PEXELS_API_KEY', 'PUPPETEER_ROOT',
9
9
  'WASYACO_ORIGIN', 'WASYACO_SIMPLE_API_KEY', 'WASYACO_SIMPLE_API_SECRET',
10
10
  ];
11
11