-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
57 lines (49 loc) · 2.48 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
use FactFinder\FfGptTools\lib\FfGptToolsCronjob;
// Check if the cronjob addon is available
if (rex_addon::get('cronjob')->isAvailable()) {
// Check if the cronjob already exists
$sql = rex_sql::factory();
$sql->setQuery('SELECT * FROM ' . rex::getTable('cronjob') . ' WHERE name = ?', ['ff_gpt_tools_cronjob']);
if ($sql->getRows() === 0) { // Cronjob doesn't exist, so add it
$sql->reset();
$sql->setTable(rex::getTable('cronjob'));
$sql->setValue('name', 'ff_gpt_tools_cronjob');
$sql->setValue('type', FfGptToolsCronjob::class);
$sql->setValue('interval', '{"minutes":"all","hours":"all,"days":"all","weekdays":"all","months":"all"}');
$sql->setValue('environment', '|script|');
$sql->setValue('execution_moment', 1); // 0 = before, 1 = after
$sql->setValue('status', 1); // 1 = active, 0 = inactive
// Set any parameters your cronjob class might require
$params = [
// Your parameters go here
];
$sql->setValue('parameters', json_encode($params));
// Insert the cronjob
$sql->insert();
// Check SQL error
if ($sql->hasError()) {
throw new rex_sql_exception('Failed to create cronjob: ' . $sql->getError());
}
}
} else {
// Error message if cronjob addon is not available
throw new rex_functional_exception('Cronjob addon is not available!');
}
rex_sql_table::get(rex::getTable('ff_gpt_tools_tasks'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('article_id', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image_id', 'varchar(191)'))
->ensureColumn(new rex_sql_column('done', 'tinyint(1)', false, '0'))
->ensureColumn(new rex_sql_column('date', 'datetime'))
->ensureColumn(new rex_sql_column('meta_description', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image_url', 'varchar(191)'))
->ensureColumn(new rex_sql_column('clang', 'varchar(191)', false, '1'))
->ensureColumn(new rex_sql_column('prompt', 'text'))
->ensureColumn(new rex_sql_column('model', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('temp', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('max_token', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('error_flag', 'int(11)', true))
->ensureColumn(new rex_sql_column('error_text', 'text', true))
->ensureColumn(new rex_sql_column('result', 'text'))
->ensure();