fix(functions): convert cron expression to timestamp

In a previous version of Appwrite, there was a next attribute with the
timestamp of when the function would be executed next. That was removed,
but the Console has not been updated to show the correct timestamp.

This PR installs cron-parser package and uses it to conver the schedule
to a human readable timestamp.
This commit is contained in:
Steven Nguyen
2024-06-22 00:05:14 +00:00
parent 351ae381a0
commit e531fe1e82
3 changed files with 29 additions and 7 deletions
+20
View File
@@ -15,6 +15,7 @@
"@stripe/stripe-js": "^3.4.0",
"ai": "^2.2.11",
"analytics": "^0.8.9",
"cron-parser": "^4.9.0",
"dayjs": "^1.11.9",
"deep-equal": "^2.2.2",
"dotenv": "^16.3.1",
@@ -4020,6 +4021,17 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/cron-parser": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-4.9.0.tgz",
"integrity": "sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==",
"dependencies": {
"luxon": "^3.2.1"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -7019,6 +7031,14 @@
"yallist": "^3.0.2"
}
},
"node_modules/luxon": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz",
"integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==",
"engines": {
"node": ">=12"
}
},
"node_modules/lz-string": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
+1
View File
@@ -28,6 +28,7 @@
"@stripe/stripe-js": "^3.4.0",
"ai": "^2.2.11",
"analytics": "^0.8.9",
"cron-parser": "^4.9.0",
"dayjs": "^1.11.9",
"deep-equal": "^2.2.2",
"dotenv": "^16.3.1",
@@ -1,24 +1,25 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Container, ContainerHeader } from '$lib/layout';
import { tooltip } from '$lib/actions/tooltip';
import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
import { CardContainer, Empty, GridItem1, Id, PaginationWithLimit } from '$lib/components';
import { toLocaleDateTime } from '$lib/helpers/date';
import { Container, ContainerHeader } from '$lib/layout';
import { app } from '$lib/stores/app';
import { isServiceLimited } from '$lib/stores/billing';
import { marketplace } from '$lib/stores/marketplace.js';
import { organization } from '$lib/stores/organization';
import { wizard } from '$lib/stores/wizard';
import { onMount } from 'svelte';
import Initial from '$lib/wizards/functions/cover.svelte';
import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
import CreateTemplate from '$lib/wizards/functions/createTemplate.svelte';
import {
templateConfig as templateConfigStore,
template as templateStore
} from '$lib/wizards/functions/store.js';
import { marketplace } from '$lib/stores/marketplace.js';
import { parseExpression } from 'cron-parser';
import { onMount } from 'svelte';
import { functionsList } from './store';
import { organization } from '$lib/stores/organization';
import { isServiceLimited } from '$lib/stores/billing';
export let data;
@@ -106,7 +107,7 @@
aria-hidden="true"
use:tooltip={{
content: `Next execution:
${toLocaleDateTime(func.schedule)}`
${toLocaleDateTime(parseExpression(func.schedule, { utc: true }).next().toString())}`
}} />
</li>
{/if}