bas 1.1.2 → 1.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f98a741f079b8f2b6a3456f7c9ace7082288174f2a3bc37743e698742c3a42a1
4
- data.tar.gz: f849ecf2d96fd6247c9e9f90085ba2aab63ba160b52c9f99b791964e8f5be97a
3
+ metadata.gz: fa7391a648acbe2845e4d72a2afea0cad5d844b7b6d667739ecf7efee409860c
4
+ data.tar.gz: 9c5f2714bd2a16f0dc396dd7e7d10afc59c4bfaf112d8e5e881a37786ba4cb1e
5
5
  SHA512:
6
- metadata.gz: bc67ff566802b434362cade800161931c80c4b5f612867abc3d55b622dd269dabc24ddf7872b20686bf4c859d60736d5bd0ed22030d0e7c4388427c1b6872bf2
7
- data.tar.gz: e43c519d0b73512148e30e9069e63e16aa792aec7ceacf639d5ba403784efca83d5399187455783426d40c17689d162b668379d0e664b3d17208213a72b6967c
6
+ metadata.gz: 38d4edb9608e7f4b65bca1573c78407499fc5662efcdbbd2b165e5208e51377a3851f665e3bd6920a060a0a643b9d2ffa8f3cf3139a513b3ecaee49f69bd1ebc
7
+ data.tar.gz: 4755d87c9ed9622e9f299dac6c70d4fcffef6ff79cac094a41ba936d4d935a50b8008c9fd19fd02baf4ce75f19126a3d52e44b69a4580eefa22cb77047ab4cc3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ # 1.1.3 (08.07.2024)
4
+ - [Update write media request to set in process](https://github.com/kommitters/bas/issues/76)
5
+
3
6
  # 1.1.2 (03.07.2024)
4
7
  - [Add gem dependencies to the specification file](https://github.com/kommitters/bas/issues/72)
5
8
 
@@ -5,6 +5,7 @@ require "json"
5
5
  require_relative "./base"
6
6
  require_relative "../read/postgres"
7
7
  require_relative "../utils/notion/request"
8
+ require_relative "../utils/notion/update_db_state"
8
9
  require_relative "../write/postgres"
9
10
 
10
11
  module Bot
@@ -47,7 +48,7 @@ module Bot
47
48
  # bot.execute
48
49
  #
49
50
  class WriteMediaReviewInNotion < Bot::Base
50
- CHUNK_SIZE = "1000"
51
+ READY_STATE = "ready"
51
52
 
52
53
  # read function to execute the PostgresDB Read component
53
54
  #
@@ -65,6 +66,8 @@ module Bot
65
66
  response = Utils::Notion::Request.execute(params)
66
67
 
67
68
  if response.code == 200
69
+ update_state
70
+
68
71
  { success: { page_id: read_response.data["page_id"], property: read_response.data["property"] } }
69
72
  else
70
73
  { error: { message: response.parsed_response, status_code: response.code } }
@@ -128,5 +131,16 @@ module Bot
128
131
  when "paragraph" then "Text review results/"
129
132
  end
130
133
  end
134
+
135
+ def update_state
136
+ data = {
137
+ property: read_response.data["property"],
138
+ page_id: read_response.data["page_id"],
139
+ state: READY_STATE,
140
+ secret: process_options[:secret]
141
+ }
142
+
143
+ Utils::Notion::UpdateDbState.execute(data)
144
+ end
131
145
  end
132
146
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "./base"
4
4
  require_relative "../read/postgres"
5
+ require_relative "../utils/notion/update_db_state"
5
6
  require_relative "../write/postgres"
6
7
 
7
8
  module Bot
@@ -53,6 +54,8 @@ module Bot
53
54
  # bot.execute
54
55
  #
55
56
  class WriteMediaReviewRequests < Bot::Base
57
+ IN_PROCESS_STATE = "in process"
58
+
56
59
  # read function to execute the PostgresDB Read component
57
60
  #
58
61
  def read
@@ -97,7 +100,20 @@ module Bot
97
100
  def write_request(request)
98
101
  return { error: request } if request["media"].empty? || !request["error"].nil?
99
102
 
103
+ update_state(request)
104
+
100
105
  { success: request }
101
106
  end
107
+
108
+ def update_state(request)
109
+ data = {
110
+ property: request["property"],
111
+ page_id: request["page_id"],
112
+ state: IN_PROCESS_STATE,
113
+ secret: process_options[:secret]
114
+ }
115
+
116
+ Utils::Notion::UpdateDbState.execute(data)
117
+ end
102
118
  end
103
119
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require_relative "request"
5
+
6
+ module Utils
7
+ module Notion
8
+ ##
9
+ # This module is a Notion utility for sending update status to notion databases.
10
+ #
11
+ module UpdateDbState
12
+ # Implements the request process logic to Notion.
13
+ #
14
+ # <br>
15
+ # <b>Params:</b>
16
+ # * <tt>property</tt> Name of the db property to be updated.
17
+ # * <tt>page_id</tt> Id of the page to be updated.
18
+ # * <tt>state</tt> State to be updated
19
+ # * <tt>secret</tt> Notion secret.
20
+ #
21
+ # <br>
22
+ # <b>returns</b> <tt>HTTParty::Response</tt>
23
+ #
24
+
25
+ def self.execute(data)
26
+ params = build_params(data)
27
+
28
+ Utils::Notion::Request.execute(params)
29
+ end
30
+
31
+ def self.build_params(data)
32
+ {
33
+ endpoint: "pages/#{data[:page_id]}",
34
+ secret: data[:secret],
35
+ method: "patch",
36
+ body: body(data)
37
+ }
38
+ end
39
+
40
+ def self.body(data)
41
+ { properties: { data[:property] => { select: { name: data[:state] } } } }
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/bas/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bas
4
4
  # Gem version
5
- VERSION = "1.1.2"
5
+ VERSION = "1.1.3"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bas
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kommitters Open Source
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gmail_xoauth
@@ -186,6 +186,7 @@ files:
186
186
  - lib/bas/utils/exceptions/invalid_process_response.rb
187
187
  - lib/bas/utils/imap/request.rb
188
188
  - lib/bas/utils/notion/request.rb
189
+ - lib/bas/utils/notion/update_db_state.rb
189
190
  - lib/bas/utils/openai/run_assistant.rb
190
191
  - lib/bas/utils/postgres/request.rb
191
192
  - lib/bas/version.rb