bas 1.5.2 → 1.6.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +92 -50
- data/lib/bas/bot/base.rb +37 -54
- data/lib/bas/shared_storage/base.rb +35 -0
- data/lib/bas/shared_storage/default.rb +18 -0
- data/lib/bas/shared_storage/postgres.rb +95 -0
- data/lib/bas/shared_storage/types/read.rb +22 -0
- data/lib/bas/utils/discord/request.rb +15 -2
- data/lib/bas/utils/openai/run_assistant.rb +1 -0
- data/lib/bas/utils/postgres/request.rb +3 -1
- data/lib/bas/version.rb +1 -1
- metadata +8 -41
- data/lib/bas/bot/compare_wip_limit_count.rb +0 -92
- data/lib/bas/bot/create_work_item.rb +0 -142
- data/lib/bas/bot/fetch_billing_from_digital_ocean.rb +0 -87
- data/lib/bas/bot/fetch_birthdays_from_notion.rb +0 -128
- data/lib/bas/bot/fetch_domain_services_from_notion.rb +0 -93
- data/lib/bas/bot/fetch_domains_wip_counts_from_notion.rb +0 -121
- data/lib/bas/bot/fetch_domains_wip_limit_from_notion.rb +0 -134
- data/lib/bas/bot/fetch_emails_from_imap.rb +0 -99
- data/lib/bas/bot/fetch_github_issues.rb +0 -147
- data/lib/bas/bot/fetch_images_from_discord.rb +0 -78
- data/lib/bas/bot/fetch_media_from_notion.rb +0 -186
- data/lib/bas/bot/fetch_next_week_birthdays_from_notion.rb +0 -142
- data/lib/bas/bot/fetch_next_week_ptos_from_notion.rb +0 -197
- data/lib/bas/bot/fetch_ptos_from_notion.rb +0 -160
- data/lib/bas/bot/format_birthdays.rb +0 -97
- data/lib/bas/bot/format_do_bill_alert.rb +0 -108
- data/lib/bas/bot/format_emails.rb +0 -124
- data/lib/bas/bot/format_wip_limit_exceeded.rb +0 -97
- data/lib/bas/bot/garbage_collector.rb +0 -85
- data/lib/bas/bot/humanize_pto.rb +0 -117
- data/lib/bas/bot/notify_discord.rb +0 -96
- data/lib/bas/bot/notify_do_bill_alert_email.rb +0 -94
- data/lib/bas/bot/review_domain_availability.rb +0 -96
- data/lib/bas/bot/review_media.rb +0 -139
- data/lib/bas/bot/update_review_media_state.rb +0 -102
- data/lib/bas/bot/update_work_item.rb +0 -181
- data/lib/bas/bot/verify_issue_existance_in_notion.rb +0 -131
- data/lib/bas/bot/write_domain_review_requests.rb +0 -104
- data/lib/bas/bot/write_media_review_in_discord.rb +0 -114
- data/lib/bas/bot/write_media_review_requests.rb +0 -104
- data/lib/bas/read/base.rb +0 -30
- data/lib/bas/read/default.rb +0 -16
- data/lib/bas/read/postgres.rb +0 -44
- data/lib/bas/read/types/response.rb +0 -18
- data/lib/bas/write/base.rb +0 -31
- data/lib/bas/write/postgres.rb +0 -45
- data/lib/bas/write/postgres_update.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd36e19f37702304576b44e8ab38c16ad18d3cb8ca59a44ff80fd8197ec2ba6
|
4
|
+
data.tar.gz: 67fd4cd540aafb0460a5a8ca4c7a630e8372483045f73298f3ccf6fe9fd3b69e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cff215e83e700143b36682d9a5dc0a222adb877a6ee525a105706b4e5f9797f21ac624627cc1f68102eecd6cc5ff2be3e4211cb42d3da1d31393dc98cef53c8
|
7
|
+
data.tar.gz: 69e0e74411e93720777fa1a4c4ae453d65b4f288f826297b38f2a208cea6aa213842f6de04fe311185ab30fb4b4671dd49e2ee19f464f9be5da58677d9bf84b4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 1.6.0 (12.11.2024)
|
4
|
+
- [Add Shared Storage Abstraction](https://github.com/kommitters/bas/issues/115)
|
5
|
+
|
6
|
+
# 1.5.3 (28.10.2024)
|
7
|
+
- [Fix response length limitations](https://github.com/kommitters/bas/issues/112)
|
8
|
+
|
3
9
|
# 1.5.2 (08.10.2024)
|
4
10
|
- [Change some details in Discord utils and review media](https://github.com/kommitters/bas/issues/108)
|
5
11
|
|
data/README.md
CHANGED
@@ -26,84 +26,126 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
26
26
|
|
27
27
|
* Ruby 2.6.0 or higher
|
28
28
|
|
29
|
-
##
|
30
|
-
A bot is a tool in charge of executing a specific automation task. The pipeline of a bot consists of reading from a data source, processing a specific task, and then writing a result in storage.
|
29
|
+
## Terms
|
31
30
|
|
32
|
-
|
33
|
-
A
|
31
|
+
### BOT
|
32
|
+
A bot is a tool responsible for executing a specific automation task. The bot's pipeline consists of reading from a shared storage (if required), processing a particular task, and then writing the result to a shared storage.
|
34
33
|
|
35
|
-
|
34
|
+
### Shared Storage
|
35
|
+
Shared storage is a central location where data can be read and written by multiple bots to facilitate coordination in an automation task. It serves as a common data exchange point, allowing each bot to access information generated by others as needed to complete its specific task. Examples of shared storage include a PostgreSQL database, an S3 bucket, or other types of storage systems that support concurrent access and data persistence.
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
The gem provides with basic interfaces, types, and methods to shape your own bot in an easy way. Since the process of reading and writing in a shared storage is separated from the main task, two base classes were defined to deal with this executions, leaving the logic of the specific task in the bot file.
|
37
|
+
### Use case
|
38
|
+
A use case refers to an automation problem larger than what a single bot can manage. It typically involves a set of bots, each solving a specific part of the overall problem independently. To enable these bots to interact, shared storage is used. This shared storage could be a PostgreSQL database, an S3 bucket, or another shared storage type, allowing bots to read and write data that other bots can access to complete their tasks.
|
40
39
|
|
41
|
-
|
40
|
+
## Building my own BOT
|
42
41
|
|
43
|
-
|
44
|
-
for building your own reader for your specific shared storage, or rely on already built classes if they match your purpose.
|
42
|
+
The gem provides essential interfaces, types, and methods to help you easily create your own bot. For instance, two base classes are provided: one for handling shared storage read-write operations and another for defining the bot’s specific task logic.
|
45
43
|
|
46
|
-
|
44
|
+
### 1. SharedStorage - Read and Write data.
|
47
45
|
|
48
|
-
|
49
|
-
The **Write** is in charge of creating or updating information in a shared storage. This is the last step for every BOT. These changes can be a transaction in a database, adding files in a cloud storage, or simply creating logs.
|
46
|
+
The `SharedStorage` class abstracts the process of reading from and writing to shared storage. This class specification is available in `bas/shared_storage/base.rb`, from which custom implementations can be built.
|
50
47
|
|
51
|
-
|
48
|
+
Currently, the gem supports: `PostgreSQL`.
|
52
49
|
|
53
|
-
###
|
54
|
-
The bot
|
50
|
+
### 2. Bot - Solve a specific automation task
|
51
|
+
The bot executes the logic required to complete a specific task. For this, an instance of shared storage (for reading and for writing) must be provided to the bot.
|
55
52
|
|
56
|
-
The base interface for a bot
|
53
|
+
The base interface for a bot is available in the `bas/bot/base.rb class`.
|
57
54
|
|
58
55
|
## Examples
|
59
56
|
|
60
|
-
In this example, we demonstrate how to instantiate a birthday notification bot and execute it in a basic Ruby project. We'll also cover its deployment in a serverless configuration, specifically using a simple Lambda deployment.
|
61
|
-
|
62
57
|
### Preparing the configurations
|
63
58
|
|
64
|
-
|
65
|
-
|
59
|
+
The current implementation of the PostgreSQL shared storage expect a table with the following structure:
|
60
|
+
|
61
|
+
```sql
|
62
|
+
CREATE TABLE api_data(
|
63
|
+
id SERIAL NOT NULL,
|
64
|
+
"data" jsonb,
|
65
|
+
tag varchar(255),
|
66
|
+
archived boolean,
|
67
|
+
stage varchar(255),
|
68
|
+
status varchar(255),
|
69
|
+
error_message jsonb,
|
70
|
+
version varchar(255),
|
71
|
+
inserted_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
|
72
|
+
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
|
73
|
+
PRIMARY KEY(id)
|
74
|
+
);
|
75
|
+
```
|
66
76
|
|
67
|
-
|
68
|
-
| -------------------- | --------------------------- | ------------------------ |
|
69
|
-
| John Doe | January 24, 2024 | January 24, 2000 |
|
70
|
-
| Jane Doe | June 20, 2024 | June 20, 2000 |
|
77
|
+
### Define the bot
|
71
78
|
|
72
|
-
|
79
|
+
In this example, we demonstrate how to configure a bot to fetch data from an API and save it in a postgres database.
|
73
80
|
|
74
|
-
|
81
|
+
For this, a bot could be defined as follow:
|
82
|
+
```ruby
|
83
|
+
require "httparty"
|
75
84
|
|
76
|
-
|
85
|
+
module Bas
|
86
|
+
module Bot
|
87
|
+
class FetchFromAPi
|
88
|
+
URL = 'some-url.com'
|
77
89
|
|
78
|
-
|
90
|
+
def process
|
91
|
+
request = HTTParty.get(URL, { headers: })
|
79
92
|
|
80
|
-
|
93
|
+
if request.code == 200
|
94
|
+
{ success: request.body }
|
95
|
+
else
|
96
|
+
{ error: request.error_message }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def headers
|
103
|
+
{
|
104
|
+
"Authorization" => "Bearer #{process_options[:token]}",
|
105
|
+
"Content-Type" => "application/json"
|
106
|
+
}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
81
111
|
```
|
112
|
+
|
113
|
+
The `Bot::Base` interface expects the process method to return a hash with a single key, which can be `success` (when the response is valid) or `error` (when an error occurs). This consistency allows SharedStorage to handle the same data types regardless of the specific bot used.
|
114
|
+
|
115
|
+
Finally, to execute the bot we could define it like follows:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
connection = {
|
119
|
+
host: "localhost",
|
120
|
+
port: 5432,
|
121
|
+
dbname: "bas",
|
122
|
+
user: "postgres",
|
123
|
+
password: "postgres"
|
124
|
+
}
|
125
|
+
|
126
|
+
read_options = {
|
127
|
+
connection:,
|
128
|
+
db_table: "api_data",
|
129
|
+
tag: "AnotherBot"
|
130
|
+
}
|
131
|
+
|
132
|
+
write_options = {
|
133
|
+
connection:,
|
134
|
+
db_table: "api_data",
|
135
|
+
tag: "FetchFromAPi"
|
136
|
+
}
|
137
|
+
|
82
138
|
options = {
|
83
|
-
|
84
|
-
database_id: "notion database id",
|
85
|
-
secret: "notion secret"
|
86
|
-
},
|
87
|
-
write_options: {
|
88
|
-
connection: {
|
89
|
-
host: "host",
|
90
|
-
port: 5432,
|
91
|
-
dbname: "bas",
|
92
|
-
user: "postgres",
|
93
|
-
password: "postgres"
|
94
|
-
},
|
95
|
-
db_table: "use_cases",
|
96
|
-
bot_name: "FetchBirthdaysFromNotion"
|
97
|
-
}
|
139
|
+
token: "api_token"
|
98
140
|
}
|
99
141
|
|
100
|
-
|
101
|
-
bot.execute
|
142
|
+
shared_storage = SharedStorage.new(read_options:, write_options:)
|
102
143
|
|
144
|
+
bot = Bas::Bot::FetchFromAPi.new(options, shared_storage)
|
145
|
+
bot.execute
|
103
146
|
```
|
104
147
|
|
105
|
-
|
106
|
-
For implementation details, please refer to the examples folder in the repository. You can find an example of how to configure a Lambda function with a bot there.
|
148
|
+
The `tag` parameter in the read and write options specifies which record to look at (when reading) and what tag to assign to the record (when writing). This way, each bot can work independently with its own records in the shared storage.
|
107
149
|
|
108
150
|
## Development
|
109
151
|
|
data/lib/bas/bot/base.rb
CHANGED
@@ -2,73 +2,56 @@
|
|
2
2
|
|
3
3
|
require_relative "../utils/exceptions/function_not_implemented"
|
4
4
|
require_relative "../utils/exceptions/invalid_process_response"
|
5
|
-
require_relative "../write/postgres_update"
|
6
5
|
|
7
|
-
module
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
module Bas
|
7
|
+
module Bot
|
8
|
+
##
|
9
|
+
# The Bot::Base class serves as the foundation for implementing specific bots. Operating
|
10
|
+
# as an interface, this class defines essential attributes and methods, providing a blueprint
|
11
|
+
# for creating custom bots formed by a Read, Process, and Write components.
|
12
|
+
#
|
13
|
+
class Base
|
14
|
+
attr_reader :process_options, :shared_storage_reader, :shared_storage_writer
|
15
|
+
attr_accessor :read_response, :process_response, :write_response
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def execute
|
24
|
-
@read_response = read
|
25
|
-
|
26
|
-
write_read_response_in_process
|
27
|
-
|
28
|
-
@process_response = process
|
29
|
-
raise Utils::Exceptions::InvalidProcessResponse unless process_response.is_a?(Hash)
|
30
|
-
|
31
|
-
write_read_response_processed
|
32
|
-
|
33
|
-
@write_response = write
|
34
|
-
end
|
17
|
+
def initialize(options, shared_storage_reader, shared_storage_writer = nil)
|
18
|
+
@process_options = options || {}
|
19
|
+
@shared_storage_reader = shared_storage_reader
|
20
|
+
@shared_storage_writer = shared_storage_writer || shared_storage_reader
|
21
|
+
end
|
35
22
|
|
36
|
-
|
23
|
+
def execute
|
24
|
+
@read_response = read
|
37
25
|
|
38
|
-
|
39
|
-
raise Utils::Exceptions::FunctionNotImplemented
|
40
|
-
end
|
26
|
+
@shared_storage_reader.set_in_process
|
41
27
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
28
|
+
@process_response = process
|
29
|
+
raise Utils::Exceptions::InvalidProcessResponse unless process_response.is_a?(Hash)
|
45
30
|
|
46
|
-
|
47
|
-
raise Utils::Exceptions::FunctionNotImplemented
|
48
|
-
end
|
31
|
+
@shared_storage_reader.set_processed
|
49
32
|
|
50
|
-
|
51
|
-
|
33
|
+
@write_response = write
|
34
|
+
end
|
52
35
|
|
53
|
-
|
54
|
-
end
|
36
|
+
protected
|
55
37
|
|
56
|
-
|
38
|
+
def read
|
39
|
+
@shared_storage_reader.read
|
40
|
+
end
|
57
41
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
options = { params: { stage: "in process" }, conditions: "id=#{read_response.id}" }
|
62
|
-
|
63
|
-
Write::PostgresUpdate.new(read_options.merge(options)).execute
|
64
|
-
end
|
42
|
+
def process
|
43
|
+
raise Utils::Exceptions::FunctionNotImplemented
|
44
|
+
end
|
65
45
|
|
66
|
-
|
67
|
-
|
46
|
+
def write
|
47
|
+
@shared_storage_writer.write(process_response)
|
48
|
+
end
|
68
49
|
|
69
|
-
|
50
|
+
def unprocessable_response
|
51
|
+
read_data = read_response.data
|
70
52
|
|
71
|
-
|
53
|
+
read_data.nil? || read_data == {} || read_data.any? { |_key, value| [[], "", nil].include?(value) }
|
54
|
+
end
|
72
55
|
end
|
73
56
|
end
|
74
57
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../utils/exceptions/function_not_implemented"
|
4
|
+
|
5
|
+
module Bas
|
6
|
+
module SharedStorage
|
7
|
+
# SharedStorage base interface
|
8
|
+
#
|
9
|
+
class Base
|
10
|
+
attr_reader :read_options, :read_response, :write_response
|
11
|
+
attr_accessor :write_options
|
12
|
+
|
13
|
+
# Initializes the read with essential configuration parameters.
|
14
|
+
#
|
15
|
+
def initialize(options = {})
|
16
|
+
@read_options = options[:read_options] || {}
|
17
|
+
@write_options = options[:write_options] || {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_in_process; end
|
21
|
+
|
22
|
+
def set_processed; end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def read
|
27
|
+
raise Utils::Exceptions::FunctionNotImplemented
|
28
|
+
end
|
29
|
+
|
30
|
+
def write
|
31
|
+
raise Utils::Exceptions::FunctionNotImplemented
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "types/read"
|
5
|
+
|
6
|
+
module Bas
|
7
|
+
module SharedStorage
|
8
|
+
##
|
9
|
+
# The SharedStorage::Default class serves as a shared storage implementation for bots
|
10
|
+
# who don't read from a <b>shared storage</b>".
|
11
|
+
#
|
12
|
+
class Default < Bas::SharedStorage::Base
|
13
|
+
def read
|
14
|
+
Bas::SharedStorage::Types::Read.new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "types/read"
|
5
|
+
require_relative "../utils/postgres/request"
|
6
|
+
require_relative "../version"
|
7
|
+
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
module Bas
|
11
|
+
module SharedStorage
|
12
|
+
##
|
13
|
+
# The SharedStorage::Postgres class serves as a shared storage implementation to read and write on
|
14
|
+
# a shared storage defined as a postgres database
|
15
|
+
#
|
16
|
+
class Postgres < Bas::SharedStorage::Base
|
17
|
+
TABLE_PARAMS = "data, tag, archived, stage, status, error_message, version"
|
18
|
+
|
19
|
+
def read
|
20
|
+
params = { connection: read_options[:connection], query: read_query }
|
21
|
+
|
22
|
+
first_result = Utils::Postgres::Request.execute(params).first || {}
|
23
|
+
|
24
|
+
@read_response = Bas::SharedStorage::Types::Read.new(first_result[:id], first_result[:data],
|
25
|
+
first_result[:inserted_at])
|
26
|
+
end
|
27
|
+
|
28
|
+
def write(data)
|
29
|
+
params = { connection: write_options[:connection], query: write_query(data) }
|
30
|
+
|
31
|
+
@write_response = Utils::Postgres::Request.execute(params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_in_process
|
35
|
+
return if read_options[:avoid_process].eql?(true) || read_response.id.nil?
|
36
|
+
|
37
|
+
update_stage(read_response.id, "in process")
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_processed
|
41
|
+
return if read_options[:avoid_process].eql?(true) || read_response.id.nil?
|
42
|
+
|
43
|
+
update_stage(read_response.id, "processed") unless @read_response.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def read_query
|
49
|
+
query = "SELECT id, data, inserted_at FROM #{read_options[:db_table]} WHERE status='success' AND #{where}"
|
50
|
+
|
51
|
+
[query, where_params]
|
52
|
+
end
|
53
|
+
|
54
|
+
def write_query(data)
|
55
|
+
query = "INSERT INTO #{write_options[:db_table]} (#{TABLE_PARAMS}) VALUES ($1, $2, $3, $4, $5, $6, $7);"
|
56
|
+
params = write_params(data)
|
57
|
+
|
58
|
+
[query, params]
|
59
|
+
end
|
60
|
+
|
61
|
+
def where
|
62
|
+
return read_options[:where] unless read_options[:where].nil?
|
63
|
+
|
64
|
+
"archived=$1 AND tag=$2 AND stage=$3 ORDER BY inserted_at ASC"
|
65
|
+
end
|
66
|
+
|
67
|
+
def where_params
|
68
|
+
return read_options[:params] unless read_options[:params].nil?
|
69
|
+
|
70
|
+
[false, read_options[:tag], "unprocessed"]
|
71
|
+
end
|
72
|
+
|
73
|
+
def write_params(data)
|
74
|
+
if data[:success]
|
75
|
+
[data[:success].to_json, write_options[:tag], false, "unprocessed", "success", nil, Bas::VERSION]
|
76
|
+
else
|
77
|
+
[nil, write_options[:tag], false, "unprocessed", "failed", data[:error].to_json, Bas::VERSION]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def update_stage(id, stage)
|
82
|
+
params = { connection: read_options[:connection], query: update_query(id, stage) }
|
83
|
+
|
84
|
+
Utils::Postgres::Request.execute(params)
|
85
|
+
end
|
86
|
+
|
87
|
+
def update_query(id, stage)
|
88
|
+
query = "UPDATE #{read_options[:db_table]} SET stage=$1 WHERE id=$2"
|
89
|
+
values = [stage, id]
|
90
|
+
|
91
|
+
[query, values]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Bas
|
6
|
+
module SharedStorage
|
7
|
+
module Types
|
8
|
+
##
|
9
|
+
# Represents a response from a read component. It encapsulates the requested data
|
10
|
+
# from the <b>shared storage</b> to be processed by a Bot.
|
11
|
+
class Read
|
12
|
+
attr_reader :id, :data, :inserted_at
|
13
|
+
|
14
|
+
def initialize(id = nil, response = nil, inserted_at = nil)
|
15
|
+
@id = id
|
16
|
+
@data = response.nil? ? {} : JSON.parse(response)
|
17
|
+
@inserted_at = inserted_at
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -39,10 +39,23 @@ module Utils
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.write_media_text(params)
|
42
|
+
def self.write_media_text(params, combined_paragraphs)
|
43
43
|
url_message = URI.parse("#{DISCORD_BASE_URL}/channels/#{params[:channel_id]}/messages")
|
44
44
|
headers = headers(params[:secret_token])
|
45
|
-
|
45
|
+
body = { content: combined_paragraphs }.to_json
|
46
|
+
|
47
|
+
HTTParty.post(url_message, { body:, headers: })
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.split_paragraphs(params)
|
51
|
+
paragraphs = params[:body].split("--DIVISION--").map(&:strip).reject(&:empty?)
|
52
|
+
|
53
|
+
paragraphs.each_slice(2) do |paragraph|
|
54
|
+
next if paragraph.empty?
|
55
|
+
|
56
|
+
combined_paragraphs = paragraph.join("\n\n")
|
57
|
+
write_media_text(params, combined_paragraphs)
|
58
|
+
end
|
46
59
|
end
|
47
60
|
|
48
61
|
def self.headers(secret_token)
|
@@ -24,7 +24,9 @@ module Utils
|
|
24
24
|
def self.execute(params)
|
25
25
|
pg_connection = PG::Connection.new(params[:connection])
|
26
26
|
|
27
|
-
execute_query(pg_connection, params[:query])
|
27
|
+
results = execute_query(pg_connection, params[:query])
|
28
|
+
|
29
|
+
results.map { |result| result.transform_keys(&:to_sym) }
|
28
30
|
end
|
29
31
|
|
30
32
|
# Execute the Postgres query
|
data/lib/bas/version.rb
CHANGED
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.
|
4
|
+
version: 1.6.0
|
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-
|
11
|
+
date: 2024-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gmail_xoauth
|
@@ -166,7 +166,7 @@ dependencies:
|
|
166
166
|
version: '1.5'
|
167
167
|
description: A versatile business automation system offering key components for building
|
168
168
|
various use cases. It provides an easy-to-use tool for implementing automation
|
169
|
-
workflows without excessive complexity. Formerly known as '
|
169
|
+
workflows without excessive complexity. Formerly known as 'bns'.
|
170
170
|
email:
|
171
171
|
- oss@kommit.co
|
172
172
|
executables: []
|
@@ -187,40 +187,10 @@ files:
|
|
187
187
|
- examples/serverless_example.md
|
188
188
|
- lib/bas.rb
|
189
189
|
- lib/bas/bot/base.rb
|
190
|
-
- lib/bas/
|
191
|
-
- lib/bas/
|
192
|
-
- lib/bas/
|
193
|
-
- lib/bas/
|
194
|
-
- lib/bas/bot/fetch_domain_services_from_notion.rb
|
195
|
-
- lib/bas/bot/fetch_domains_wip_counts_from_notion.rb
|
196
|
-
- lib/bas/bot/fetch_domains_wip_limit_from_notion.rb
|
197
|
-
- lib/bas/bot/fetch_emails_from_imap.rb
|
198
|
-
- lib/bas/bot/fetch_github_issues.rb
|
199
|
-
- lib/bas/bot/fetch_images_from_discord.rb
|
200
|
-
- lib/bas/bot/fetch_media_from_notion.rb
|
201
|
-
- lib/bas/bot/fetch_next_week_birthdays_from_notion.rb
|
202
|
-
- lib/bas/bot/fetch_next_week_ptos_from_notion.rb
|
203
|
-
- lib/bas/bot/fetch_ptos_from_notion.rb
|
204
|
-
- lib/bas/bot/format_birthdays.rb
|
205
|
-
- lib/bas/bot/format_do_bill_alert.rb
|
206
|
-
- lib/bas/bot/format_emails.rb
|
207
|
-
- lib/bas/bot/format_wip_limit_exceeded.rb
|
208
|
-
- lib/bas/bot/garbage_collector.rb
|
209
|
-
- lib/bas/bot/humanize_pto.rb
|
210
|
-
- lib/bas/bot/notify_discord.rb
|
211
|
-
- lib/bas/bot/notify_do_bill_alert_email.rb
|
212
|
-
- lib/bas/bot/review_domain_availability.rb
|
213
|
-
- lib/bas/bot/review_media.rb
|
214
|
-
- lib/bas/bot/update_review_media_state.rb
|
215
|
-
- lib/bas/bot/update_work_item.rb
|
216
|
-
- lib/bas/bot/verify_issue_existance_in_notion.rb
|
217
|
-
- lib/bas/bot/write_domain_review_requests.rb
|
218
|
-
- lib/bas/bot/write_media_review_in_discord.rb
|
219
|
-
- lib/bas/bot/write_media_review_requests.rb
|
220
|
-
- lib/bas/read/base.rb
|
221
|
-
- lib/bas/read/default.rb
|
222
|
-
- lib/bas/read/postgres.rb
|
223
|
-
- lib/bas/read/types/response.rb
|
190
|
+
- lib/bas/shared_storage/base.rb
|
191
|
+
- lib/bas/shared_storage/default.rb
|
192
|
+
- lib/bas/shared_storage/postgres.rb
|
193
|
+
- lib/bas/shared_storage/types/read.rb
|
224
194
|
- lib/bas/utils/digital_ocean/request.rb
|
225
195
|
- lib/bas/utils/discord/integration.rb
|
226
196
|
- lib/bas/utils/discord/request.rb
|
@@ -238,9 +208,6 @@ files:
|
|
238
208
|
- lib/bas/utils/openai/run_assistant.rb
|
239
209
|
- lib/bas/utils/postgres/request.rb
|
240
210
|
- lib/bas/version.rb
|
241
|
-
- lib/bas/write/base.rb
|
242
|
-
- lib/bas/write/postgres.rb
|
243
|
-
- lib/bas/write/postgres_update.rb
|
244
211
|
- renovate.json
|
245
212
|
- sig/business_automation_system.rbs
|
246
213
|
homepage: https://github.com/kommitters/bas
|
@@ -264,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
231
|
- !ruby/object:Gem::Version
|
265
232
|
version: '0'
|
266
233
|
requirements: []
|
267
|
-
rubygems_version: 3.5.
|
234
|
+
rubygems_version: 3.5.22
|
268
235
|
signing_key:
|
269
236
|
specification_version: 4
|
270
237
|
summary: BAS - Business automation system
|