Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
protogrid:agents [2021-06-06 22:26] – 185.110.184.205 | protogrid:agents [2021-06-23 11:25] – Hinweis auf Performance-Beeinträchtigung von include_cards eingefügt. dru |
---|
===== Execution ====== | ===== Execution ====== |
Agents are by default checked every hour (this can be modified for your environment, please contact the Protogrid Operations Team). If any DateTime Field on a card has a smaller value than the current time and the Agent has not yet run since that time, the Agent gets triggered and the code in the Agent Library is executed in the context of this card (for Date-Only Fields, the time taken into account is said date, 00:00 GMT). Agents run in the context of a specific user profile. This user's password is automatically reset during the execution process. So this user profile shall only be used for agents and not for physical users. All agent executions are logged in the //agent_log// on the respective card. | Agents are by default checked every hour (this can be modified for your environment, please contact the Protogrid Operations Team). If any DateTime Field on a card has a smaller value than the current time and the Agent has not yet run since that time, the Agent gets triggered and the code in the Agent Library is executed in the context of this card (for Date-Only Fields, the time taken into account is said date, 00:00 GMT). Agents run in the context of a specific user profile. This user's password is automatically reset during the execution process. So this user profile shall only be used for agents and not for physical users. All agent executions are logged in the //agent_log// on the respective card. |
| |
| While an agent is running in the context of a specific card, it is also possible to load and save other cards by calling the JSON API endpoints using axios. A valid axios module is given in the //on_schedule// function. Agents have a global runtime limit (usually one hour). If you want to restrict this limit for certain agents, you can do so by entering the desired maximum runtime (in milliseconds) in the Agent card. After reaching the runtime limit, the code will terminate instantly and the next card will be processed. The process will not be started if the time until the next agent check is less than the maximum runtime. |
| |
| The //on_schedule// function should return a boolean. If the boolean is true, the card that triggered the agent will be saved. |
| |
===== Best Practices for Calculation Code ====== | ===== Best Practices for Calculation Code ====== |
- Procedure if the calculation code requires a "relation" that does not need a Relation Field in the user interface: Use a Text Field instead of a Relation Field. Write the key of the relation to this Text Field with an individual prefix (important!). Use a Text Filter or a dedicated [[protogrid:TableView#Search Dialog Boxes|Search Dialog Box]] to retrieve Cards with the desired relation. | - Procedure if the calculation code requires a "relation" that does not need a Relation Field in the user interface: Use a Text Field instead of a Relation Field. Write the key of the relation to this Text Field with an individual prefix (important!). Use a Text Filter or a dedicated [[protogrid:TableView#Search Dialog Boxes|Search Dialog Box]] to retrieve Cards with the desired relation. |
- If editing or deleting a Card in the user interface subsequently to calculation has to be prevented, this can be done in both cases by restricting the editing rights ([[protogrid:Role|roles]] at Proto and/or Card level). | - If editing or deleting a Card in the user interface subsequently to calculation has to be prevented, this can be done in both cases by restricting the editing rights ([[protogrid:Role|roles]] at Proto and/or Card level). |
- Read/load as few specific/single cards as possible. Work with views whenever possible. Use "include_cards" - but only if necessary. Do not hesitate to contact Protogrid Customer Support proactively in case of special requirements (e.g. certain values needed in the value of a view row or special reduction views needed). | - Read/load as few specific/single cards as possible. Work with views whenever possible. Use "include_cards" - but only if necessary and on as few view rows as possible. Do not hesitate to contact Protogrid Customer Support proactively in case of special requirements (e.g. certain values needed in the value of a view row or special reduction views needed). |
- Analogous to the previous point, write as few specific/single cards as possible. Whenever possible, save several cards together. You can use the Endpoint [[protogrid:API Endpoints#/api/v2/apps/<app_name>/cards|/api/v2/apps/<app_name>/cards]] with a list of Card objects in the POST body. | - Analogous to the previous point, write as few specific/single cards as possible. Whenever possible, save several cards together. You can use the Endpoint [[protogrid:API Endpoints#/api/v2/apps/<app_name>/cards|/api/v2/apps/<app_name>/cards]] with a list of Card objects in the POST body. |