Skip to content

Commit a2ae3e6

Browse files
committed
Migrated state:progress command into the new events system, thus it's no longer a task but an event. as such, the related ENVS and command are gone.
1 parent b4c74c1 commit a2ae3e6

File tree

14 files changed

+385
-431
lines changed

14 files changed

+385
-431
lines changed

FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ command via CLI.
402402

403403
> [!IMPORTANT]
404404
> for environment variables that has `{TASK}` tag, you **MUST** replace it with one
405-
> of `IMPORT`, `EXPORT`, `PUSH`, `BACKUP`, `PRUNE`, `INDEXES`, `REQUESTS`. To see tasks active settings run
405+
> of `IMPORT`, `EXPORT`, `PUSH`, `BACKUP`, `PRUNE`, `INDEXES`. To see tasks active settings run
406406
407407
```bash
408408
$ docker exec -ti watchstate console system:tasks

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ out of the box, this tool support `Jellyfin`, `Plex` and `Emby` media servers.
99

1010
## Updates
1111

12+
### 2024-08-18
13+
14+
We have started migrating the old events system to a new one, so far we have migrated the `progress` and `requests` to it. As such,
15+
The old tasks `state:progress` and `state:requests` are now gone. To control if you want to enable the watch progress, there is new
16+
environment variable `WS_SYNC_PROGRESS` which you can set to `true` to enable the watch progress. It's disabled by default.
17+
18+
We will continue to migrate the rest of the events to the new system, and we will keep you updated.
19+
1220
### 2024-08-10
1321

1422
I have recently added new experimental feature, to play your content directly from the WebUI. This feature is still in

config/config.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use App\Commands\State\BackupCommand;
1010
use App\Commands\State\ExportCommand;
1111
use App\Commands\State\ImportCommand;
12-
use App\Commands\State\ProgressCommand;
1312
use App\Commands\State\PushCommand;
1413
use App\Commands\System\IndexCommand;
1514
use App\Commands\System\PruneCommand;
@@ -75,6 +74,9 @@
7574
'proxy' => (bool)env('WS_TRUST_PROXY', false),
7675
'header' => (string)env('WS_TRUST_HEADER', 'X-Forwarded-For'),
7776
],
77+
'sync' => [
78+
'progress' => (bool)env('WS_SYNC_PROGRESS', false),
79+
],
7880
];
7981

8082
$config['backends_file'] = fixPath(env('WS_BACKENDS_FILE', ag($config, 'path') . '/config/servers.yaml'));
@@ -272,14 +274,6 @@
272274
'timer' => $checkTaskTimer((string)env('WS_CRON_PUSH_AT', '*/10 * * * *'), '*/10 * * * *'),
273275
'args' => env('WS_CRON_PUSH_ARGS', '-v'),
274276
],
275-
ProgressCommand::TASK_NAME => [
276-
'command' => ProgressCommand::ROUTE,
277-
'name' => ProgressCommand::TASK_NAME,
278-
'info' => 'Send play progress to backends.',
279-
'enabled' => (bool)env('WS_CRON_PROGRESS', false),
280-
'timer' => $checkTaskTimer((string)env('WS_CRON_PROGRESS_AT', '*/45 * * * *'), '*/45 * * * *'),
281-
'args' => env('WS_CRON_PROGRESS_ARGS', '-v'),
282-
],
283277
BackupCommand::TASK_NAME => [
284278
'command' => BackupCommand::ROUTE,
285279
'name' => BackupCommand::TASK_NAME,

config/env.spec.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@
161161
'description' => 'All executing all commands in the console. They must be prefixed with $',
162162
'type' => 'bool',
163163
],
164+
[
165+
'key' => 'WS_SYNC_PROGRESS',
166+
'description' => 'Enable watch progress sync.',
167+
'type' => 'bool',
168+
],
164169
];
165170

166171
$validateCronExpression = function (string $value): string {
@@ -186,7 +191,7 @@
186191
};
187192

188193
// -- Do not forget to update the tasks list if you add a new task.
189-
$tasks = ['import', 'export', 'push', 'progress', 'backup', 'prune', 'indexes'];
194+
$tasks = ['import', 'export', 'push', 'backup', 'prune', 'indexes'];
190195
$task_env = [
191196
[
192197
'key' => 'WS_CRON_{TASK}',

frontend/pages/events/view.vue

+13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@
8585
JSON.stringify(item.logs, null, 2)
8686
}}</code></pre>
8787
</div>
88+
<div class="column is-12" v-if="item.options">
89+
<h2 class="title is-4 is-clickable is-unselectable" @click="toggleOptions = !toggleOptions">
90+
<span class="icon">
91+
<i class="fas" :class="{ 'fa-arrow-down': !toggleOptions, 'fa-arrow-up': toggleOptions }"></i>
92+
</span>&nbsp;
93+
<span>Show attached options</span>
94+
</h2>
95+
<pre class="p-0 is-pre-wrap" v-if="toggleOptions"><code
96+
style="word-break: break-word" class="language-json">{{
97+
JSON.stringify(item.options, null, 2)
98+
}}</code></pre>
99+
</div>
88100
</div>
89101
</div>
90102
</template>
@@ -105,6 +117,7 @@ const item = ref({})
105117
106118
const toggleLogs = useStorage('events_toggle_logs', true)
107119
const toggleData = useStorage('events_toggle_data', true)
120+
const toggleOptions = useStorage('events_toggle_options', true)
108121
109122
onMounted(async () => {
110123
if (!id.value) {

src/API/Backend/Webhooks.php

+6-16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use App\Libs\Uri;
1717
use App\Listeners\ProcessRequestEvent;
1818
use App\Model\Events\EventsTable;
19-
use DateInterval;
2019
use Monolog\Handler\StreamHandler;
2120
use Monolog\Level;
2221
use Monolog\Logger;
@@ -199,23 +198,14 @@ private function process(string $name, iRequest $request): iResponse
199198
'id' => ag($entity->getMetadata($entity->via), iState::COLUMN_ID, '??'),
200199
]);
201200

202-
queueEvent(ProcessRequestEvent::NAME, [
203-
'options' => [
204-
Options::IMPORT_METADATA_ONLY => $metadataOnly,
205-
],
206-
'entity' => $entity->getAll(),
207-
], [
208-
EventsTable::COLUMN_REFERENCE => $itemId,
201+
queueEvent(ProcessRequestEvent::NAME, $entity->getAll(), [
209202
'unique' => true,
203+
EventsTable::COLUMN_REFERENCE => $itemId,
204+
EventsTable::COLUMN_OPTIONS => [
205+
Options::IMPORT_METADATA_ONLY => $metadataOnly,
206+
]
210207
]);
211208

212-
$pEnabled = (bool)env('WS_CRON_PROGRESS', false);
213-
if ($pEnabled && false === $metadataOnly && true === $entity->hasPlayProgress() && !$entity->isWatched()) {
214-
$progress = $this->cache->get('progress', []);
215-
$progress[str_replace($itemId, ':tainted@', ':untainted@')] = $entity;
216-
$this->cache->set('progress', $progress, new DateInterval('P3D'));
217-
}
218-
219209
$this->write($request, Level::Info, 'Queued [{backend}: {event}] {item.type} [{item.title}].', [
220210
'backend' => $entity->via,
221211
'event' => ag($entity->getExtra($entity->via), iState::COLUMN_EXTRA_EVENT),
@@ -225,7 +215,7 @@ private function process(string $name, iRequest $request): iResponse
225215
'type' => $entity->type,
226216
'played' => $entity->isWatched() ? 'Yes' : 'No',
227217
'queue_id' => $itemId,
228-
'progress' => $pEnabled && $entity->hasPlayProgress() ? $entity->getPlayProgress() : null,
218+
'progress' => $entity->hasPlayProgress() ? $entity->getPlayProgress() : null,
229219
]
230220
]
231221
);

0 commit comments

Comments
 (0)