wco_models 3.1.0.83 → 3.1.0.86
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/wco/office_action_templates_controller.rb +0 -3
- data/app/controllers/wco/office_actions_controller.rb +0 -3
- data/app/models/wco/headline.rb +2 -1
- data/app/models/wco/office_action.rb +18 -2
- data/app/models/wco/office_action_template.rb +1 -1
- data/app/models/wco/office_action_template_tie.rb +3 -2
- data/app/models/wco/publisher.rb +6 -2
- data/app/models/wco/report.rb +2 -13
- data/app/views/wco/office_action_templates/_ties.haml +6 -6
- data/app/views/wco/office_actions/_index.haml +2 -0
- data/lib/tasks/office_tasks.rake +11 -19
- data/lib/wco/ai_writer.rb +6 -6
- data/lib/wco_models.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b766aa1273a9c863ee71e44e96308ac8ff2de76e4a29079bcf58a23cdc50298b
|
4
|
+
data.tar.gz: 5c032aa7fac857e68baf760863d0d3de1831de98e1cbf52397c117fa2db41454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f539fda62b5de3856bc7fab46585ad1ffe13be1a9f8285e70d11b2bf327d3887a2f5e63815887abb5ea79164ffc733392f6fa69d9931882428f74cacbed2dbc
|
7
|
+
data.tar.gz: 98d693ef2b7b0b762b6677e42f1ba2c414f3195b1ea00f009bf55b09e1a03618bf1164e4cef342dca3032baa34294a1c29dacc511c9595ac0b866d510924ba03
|
data/app/models/wco/headline.rb
CHANGED
@@ -12,7 +12,8 @@ class Wco::Headline
|
|
12
12
|
field :name
|
13
13
|
validates :name, presence: true, uniqueness: true
|
14
14
|
|
15
|
-
|
15
|
+
## @TODO: remove this entirely. 2024-01-16
|
16
|
+
belongs_to :site, class_name: 'Wco::Site', optional: true
|
16
17
|
|
17
18
|
has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
|
18
19
|
|
@@ -23,9 +23,25 @@ class Wco::OfficeAction
|
|
23
23
|
|
24
24
|
field :perform_at, type: :time
|
25
25
|
|
26
|
+
def do_run
|
27
|
+
sch = self
|
28
|
+
sch.update!({ status: STATUS_INACTIVE })
|
29
|
+
|
30
|
+
eval( sch.tmpl.action_exe )
|
31
|
+
|
32
|
+
# schedule next actions & update the action
|
33
|
+
sch.tmpl.ties.each do |tie|
|
34
|
+
next_sch = self.class.find_or_initialize_by({
|
35
|
+
office_action_template_id: tie.next_tmpl.id,
|
36
|
+
})
|
37
|
+
next_sch.perform_at = eval(tie.next_at_exe)
|
38
|
+
next_sch.status = STATUS_ACTIVE
|
39
|
+
next_sch.save!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
26
43
|
def to_s
|
27
44
|
slug
|
28
45
|
end
|
29
|
-
|
30
46
|
end
|
31
|
-
|
47
|
+
OA ||= Wco::OfficeAction
|
@@ -7,10 +7,10 @@ class Wco::OfficeActionTemplateTie
|
|
7
7
|
attr_accessor :to_delete
|
8
8
|
|
9
9
|
belongs_to :office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :ties
|
10
|
-
def
|
10
|
+
def tmpl; office_action_template; end
|
11
11
|
|
12
12
|
belongs_to :next_office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :prev_ties
|
13
|
-
def
|
13
|
+
def next_tmpl; next_office_action_template; end
|
14
14
|
# def tmpl; next_office_action_template; end
|
15
15
|
|
16
16
|
|
@@ -18,3 +18,4 @@ class Wco::OfficeActionTemplateTie
|
|
18
18
|
validates :next_at_exe, presence: true
|
19
19
|
|
20
20
|
end
|
21
|
+
OATT ||= Wco::OfficeActionTemplateTie
|
data/app/models/wco/publisher.rb
CHANGED
@@ -28,6 +28,7 @@ class Wco::Publisher
|
|
28
28
|
@headers = {}
|
29
29
|
@ctx = OpenStruct.new
|
30
30
|
|
31
|
+
puts! context_eval, 'context_eval'
|
31
32
|
eval( context_eval )
|
32
33
|
puts! @ctx, '@ctx'
|
33
34
|
|
@@ -38,11 +39,14 @@ class Wco::Publisher
|
|
38
39
|
out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
|
39
40
|
body: body.to_json,
|
40
41
|
headers: @headers,
|
41
|
-
basic_auth: { username: site.username, password: site.password },
|
42
|
+
basic_auth: { username: @site.username, password: @site.password },
|
42
43
|
})
|
43
44
|
puts! out.response, 'out'
|
45
|
+
if out.code != 201
|
46
|
+
raise "#do_run exception: #{out.body}"
|
47
|
+
end
|
44
48
|
|
45
|
-
eval( after_eval )
|
49
|
+
eval( after_eval ) if after_eval.present?
|
46
50
|
end
|
47
51
|
|
48
52
|
|
data/app/models/wco/report.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
|
2
2
|
##
|
3
|
+
## @report.body.split("\n\n").map { |ttt| "<p>#{ttt}</p>" }.join
|
3
4
|
##
|
4
|
-
##
|
5
|
-
# @report.body.split("\n\n").map { |ttt| "<p>#{ttt}</p>" }.join
|
6
|
-
#
|
7
5
|
class Wco::Report
|
8
6
|
include Mongoid::Document
|
9
7
|
include Mongoid::Timestamps
|
@@ -21,19 +19,10 @@ class Wco::Report
|
|
21
19
|
field :slug
|
22
20
|
validates :slug, presence: true, uniqueness: true
|
23
21
|
index({ :slug => 1 }, { :unique => true })
|
24
|
-
before_validation :set_slug, :
|
22
|
+
before_validation :set_slug, on: :create
|
25
23
|
|
26
24
|
field :body
|
27
25
|
|
28
|
-
# field :raw_json, type: :object, default: '{}'
|
29
|
-
|
30
|
-
# field :is_trash, :type => Boolean, :default => false
|
31
|
-
# index({ :is_trash => 1, :is_public => 1 })
|
32
|
-
|
33
|
-
# field :is_public, :type => Boolean, :default => true
|
34
|
-
# index({ :is_public => 1 })
|
35
|
-
# scope :public, ->{ where({ is_public: true }) }
|
36
|
-
|
37
26
|
field :x, :type => Float
|
38
27
|
field :y, :type => Float
|
39
28
|
field :z, :type => Float
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
-
|
2
|
+
- tmpl ||= nil
|
3
3
|
- depth ||= 5
|
4
4
|
- depth = depth - 1
|
5
5
|
|
@@ -10,9 +10,9 @@
|
|
10
10
|
%li
|
11
11
|
= tie.next_at_exe
|
12
12
|
%br
|
13
|
-
= link_to '[~]', edit_office_action_template_path(tie.
|
14
|
-
= link_to tie.
|
15
|
-
- if tie.
|
13
|
+
= link_to '[~]', edit_office_action_template_path(tie.next_tmpl)
|
14
|
+
= link_to tie.next_tmpl, office_action_template_path(tie.next_tmpl)
|
15
|
+
- if tie.next_tmpl == tmpl
|
16
16
|
<b>[Same]</b>
|
17
|
-
- elsif tie.
|
18
|
-
= render '/wco/office_action_templates/ties', ties: tie.
|
17
|
+
- elsif tie.next_tmpl.ties.present?
|
18
|
+
= render '/wco/office_action_templates/ties', ties: tie.next_tmpl.ties, depth: depth, tmpl: tie.next_tmpl
|
data/lib/tasks/office_tasks.rake
CHANGED
@@ -2,34 +2,26 @@
|
|
2
2
|
require 'business_time'
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
namespace :
|
5
|
+
namespace :wco do
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
desc 'run office actions'
|
8
9
|
task run_office_actions: :environment do
|
10
|
+
puts! "Starting wco_email:run_office_actions..."
|
9
11
|
while true do
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
OA.active.where( :perform_at.lte => Time.now ).each do |oa|
|
15
|
-
puts "+++ +++ Office Action: #{oa}"
|
13
|
+
schs = Wco::OfficeAction.active.where({ :perform_at.lte => Time.now })
|
14
|
+
print "[#{schs.length}]" if schs.length != 0
|
15
|
+
schs.each do |sch|
|
16
16
|
|
17
|
-
|
18
|
-
oa.tmpl.do_run
|
19
|
-
oa.tmpl.ties.each do |tie|
|
20
|
-
next_oa = OA.find_or_initialize_by({
|
21
|
-
office_action_template_id: tie.next_oat.id,
|
22
|
-
})
|
23
|
-
next_oa.perform_at = eval( tie.next_at_exe )
|
24
|
-
next_oa.status = ACTIVE
|
25
|
-
next_oa.save!
|
26
|
-
end
|
17
|
+
sch.do_run
|
27
18
|
|
28
|
-
print
|
19
|
+
print "[#{sch.id}]^"
|
20
|
+
sleep 15
|
29
21
|
end
|
30
22
|
|
31
23
|
print '.'
|
32
|
-
sleep
|
24
|
+
sleep 15
|
33
25
|
end
|
34
26
|
end
|
35
27
|
|
data/lib/wco/ai_writer.rb
CHANGED
@@ -21,6 +21,7 @@ class Wco::AiWriter
|
|
21
21
|
})
|
22
22
|
out = JSON.parse out.response.body
|
23
23
|
out.deep_symbolize_keys!
|
24
|
+
puts! out, 'chatgpt response'
|
24
25
|
out = out[:choices][0][:message][:content]
|
25
26
|
return out
|
26
27
|
end
|
@@ -28,25 +29,24 @@ class Wco::AiWriter
|
|
28
29
|
|
29
30
|
|
30
31
|
def self.run_headline headline
|
31
|
-
prompt = "Rephrase the following article title using
|
32
|
+
prompt = "Rephrase the following article title using less than 250 characters: #{headline.name}"
|
32
33
|
new_title = self.run_prompt prompt
|
33
|
-
|
34
|
+
new_title = new_title[0..255]
|
35
|
+
# puts! new_title, 'new_title'
|
34
36
|
|
35
37
|
prompt = "Write an article about the following topic: #{headline.name}"
|
36
38
|
new_body = self.run_prompt prompt
|
37
39
|
new_body.gsub!("\r", '')
|
38
40
|
new_body = new_body.split("\n\n").map { |ppp| "<p>#{ppp}</p>" }.join
|
39
41
|
new_body = new_body.gsub("\n", "<br />")
|
40
|
-
puts! new_body[0...200], 'new_body'
|
42
|
+
# puts! new_body[0...200], 'new_body'
|
41
43
|
|
42
44
|
report = Wco::Report.create!({
|
43
45
|
title: new_title,
|
44
|
-
slug:
|
46
|
+
# slug: new_title,
|
45
47
|
body: new_body,
|
46
48
|
})
|
47
49
|
|
48
|
-
# headline.delete
|
49
|
-
|
50
50
|
return report
|
51
51
|
end
|
52
52
|
def run_headline h; self.class.run_headline h; end
|
data/lib/wco_models.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wco_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.86
|
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-
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|