Skip to content

Commit cf60992

Browse files
authored
Merge pull request #13596 from nextcloud/enh/noid/taskprocessing-new-manager-method
Include new task processing manager method in developer doc
2 parents ebcddb3 + 38de89f commit cf60992

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_32.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Added APIs
125125

126126
- New task processing task type ``OCP\TaskProcessing\TextToSpeech`` to convert text to speech.
127127
- New task processing task type ``OCP\TaskProcessing\AnalyzeImages`` to ask questions about images.
128-
128+
- New method ``OCP\TaskProcessing\Manager::getAvailableTaskTypeIds`` to list only task type IDs without meta-data (faster than ``OCP\TaskProcessing\Manager::getAvailableTaskTypes``)
129129

130130
Changed APIs
131131
^^^^^^^^^^^^

developer_manual/digging_deeper/task_processing.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ To consume the Task Processing API, you will need to :ref:`inject<dependency-in
1515

1616
* ``hasProviders()`` This method returns a boolean which indicates if any providers have been registered. If this is false you cannot use the TextProcessing feature.
1717
* ``getAvailableTaskTypes(bool $showDisabled = false)`` This method returns an array of enabled task types indexed by their ID with their names and additional metadata. If you set ``$showdisabled`` to ``true`` (available since NC31), it will include disabled task types.
18+
* ``getAvailableTaskTypeIds()`` This method (available since NC32) returns a list of available task type IDs. It uses the same logic as ``getAvailableTaskTypes()`` but is faster because it does not compute the task types metadata (which can be slow when getting default field values or multiselect value lists). If you just want to check if a feature is available, prefer using this method rather than ``getAvailableTaskTypes()``.
1819
* ``scheduleTask(Task $task)`` This method provides the actual scheduling functionality. The task is defined using the Task class. This method runs the task asynchronously in a background job.
1920
* ``getTask(int $id)`` This method fetches a task specified by its id.
2021
* ``deleteTask(Task $task)`` This method deletes a task
@@ -210,7 +211,10 @@ To create a task we use the ``\OCP\TaskProcessing\Task`` class. Its constructor
210211

211212
.. code-block:: php
212213
213-
if (isset($textprocessingManager->getAvailableTaskTypes()[TextToTextSummary::ID]) {
214+
// getAvailableTaskTypeIds is faster than getAvailableTaskTypes
215+
// if (isset($textprocessingManager->getAvailableTaskTypes()[TextToTextSummary::ID]) {
216+
// if you don't need the task type metadata, prefer this:
217+
if (in_array(TextToTextSummary::ID, $textprocessingManager->getAvailableTaskTypeIds(), true) {
214218
$summaryTask = new Task(TextToTextSummary::ID, $emailText, "my_app", $userId, (string) $emailId);
215219
} else {
216220
// cannot use summarization

0 commit comments

Comments
 (0)