Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/backend/effects/queues/effect-queue-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class EffectQueueManager extends JsonDbManager {
}

item.queue = effectQueueRunner.getQueue(itemId);

item.length = item.queue.length;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this so the express api also has easy access to this value. Its present when calling for all queues but not individual queues so assume just a small oversight.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I implemented that originally, the paradigm was "fetch all queues, get length. Fetch specific queue, get the array of items instead for more advanced use"

the intention there was that if you needed the length, you'd get it from the array as the array is already present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely get it, I'm adding it for the less capable tools that can fetch against the api but only take the json key and don't permit any type of count/logic capabilities.

return item;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ReplaceVariable } from "../../../../types/variables";
import { OutputDataType, VariableCategory } from "../../../../shared/variable-constants";

import effectQueueManager from "../../../effects/queues/effect-queue-manager";

const model : ReplaceVariable = {
definition: {
handle: "effectQueueLength",
usage: "effectQueueLength[queueName]",
description: "Returns the length of an effect queue. Useful for showing queue length in a command response.",
categories: [VariableCategory.ADVANCED],
possibleDataOutput: [OutputDataType.TEXT]
},
evaluator: async (_trigger, text = "") => {
const selectedQueue = effectQueueManager.getAllItems().find((queue) => queue.name === text);
if (selectedQueue) {
return selectedQueue.length.toString();
}
return "Unknown";
}
};

export default model;
2 changes: 2 additions & 0 deletions src/backend/variables/builtin/utility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import fileExists from './file-exists';
import fileLineCount from './file-line-count';
import fileRead from './file-read';
import filesInDirectory from './files-in-directory';
import getEffectQueueLength from "./get-effect-queue-length"
import loopCount from './loop-count';
import loopItem from './loop-item';
import quickstore from './quick-store';
Expand All @@ -27,6 +28,7 @@ export default [
fileLineCount,
fileRead,
filesInDirectory,
getEffectQueueLength,
loopCount,
loopItem,
quickstore,
Expand Down