diff --git a/client/shared b/client/shared index 9f10925a..4245d533 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 9f10925a6308c9d6ed371e87146f75786a8ec8fb +Subproject commit 4245d53311003e49b730ff6fc8b85bf92f89626a diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index ab128048..5b250f27 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -28,6 +28,7 @@ export default [ { html: 'הוספת אפשרות למנהלת להתקשר ולשמוע אילו מורות דיווחו נוכחות היום', status: 'בוצע', statusColor: 'success' }, { html: 'הוספת דוח המציג אילו מורות דיווחו נוכחות בתאריך נבחר', status: 'בוצע', statusColor: 'success' }, { html: 'הוספת דף "צור קשר" לשליחת פנייה עם קבצים מצורפים', status: 'בוצע', statusColor: 'success' }, + { html: 'תשתית משימות רקע: ייצוא נתונים אסינכרוני, תזמונים קבועים וניטור משימות', status: 'בוצע', statusColor: 'success' }, // { html: 'הגדרת תקופת זמן לפי תאריכים', status: 'בקרוב', statusColor: 'warning' }, // { html: 'הגדרת תקופת זמן לפי יום בשבוע', status: 'בוצע', statusColor: 'success' }, diff --git a/server/package.json b/server/package.json index f3b66331..5a23fe07 100644 --- a/server/package.json +++ b/server/package.json @@ -42,6 +42,7 @@ "@nestjs/mapped-types": "*", "@nestjs/passport": "^9.0.0", "@nestjs/platform-express": "^9.0.0", + "@nestjs/schedule": "^3.0.4", "@nestjs/swagger": "^6.3.0", "@nestjs/throttler": "^4.0.0", "@nestjs/typeorm": "^9.0.1", @@ -52,6 +53,7 @@ "axios": "^1.3.4", "bcrypt": "^5.1.0", "change-case": "^4.1.2", + "cron-parser": "^4.9.0", "class-transformer": "^0.5.1", "class-validator": "0.13", "cookie-parser": "^1.4.6", diff --git a/server/shared b/server/shared index 3a7a104e..0c3ea446 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 3a7a104eee7dac4447bcf2429fd1e2f8983e675b +Subproject commit 0c3ea44661df6a39bee000086fcdd8544b2be2bf diff --git a/server/src/migrations/1787100000000-addJobsAndSchedulesTables.ts b/server/src/migrations/1787100000000-addJobsAndSchedulesTables.ts new file mode 100644 index 00000000..cfbfc7e6 --- /dev/null +++ b/server/src/migrations/1787100000000-addJobsAndSchedulesTables.ts @@ -0,0 +1,61 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class addJobsAndSchedulesTables1787100000000 implements MigrationInterface { + name = 'addJobsAndSchedulesTables1787100000000' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + CREATE TABLE IF NOT EXISTS \`jobs\` ( + \`id\` int NOT NULL AUTO_INCREMENT, + \`user_id\` int NOT NULL, + \`type\` varchar(100) NOT NULL, + \`status\` varchar(20) NOT NULL DEFAULT 'pending', + \`payload\` longtext NULL, + \`result\` longtext NULL, + \`progress\` int NOT NULL DEFAULT '0', + \`attempts\` int NOT NULL DEFAULT '0', + \`max_attempts\` int NOT NULL DEFAULT '3', + \`available_at\` datetime NULL, + \`locked_at\` datetime NULL, + \`locked_by\` varchar(100) NULL, + \`dedupe_key\` varchar(191) NULL, + \`error\` text NULL, + \`created_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updated_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + \`completed_at\` datetime NULL, + PRIMARY KEY (\`id\`), + INDEX \`job_user_id_idx\` (\`user_id\`), + INDEX \`job_type_idx\` (\`type\`), + INDEX \`job_status_idx\` (\`status\`), + INDEX \`job_available_at_idx\` (\`available_at\`), + INDEX \`job_dedupe_key_idx\` (\`dedupe_key\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + `); + + await queryRunner.query(` + CREATE TABLE IF NOT EXISTS \`schedules\` ( + \`id\` int NOT NULL AUTO_INCREMENT, + \`user_id\` int NOT NULL, + \`name\` varchar(255) NOT NULL, + \`job_type\` varchar(100) NOT NULL, + \`payload\` text NULL, + \`cron_expression\` varchar(120) NOT NULL, + \`time_zone\` varchar(60) NOT NULL DEFAULT 'Asia/Jerusalem', + \`active\` tinyint(1) NOT NULL DEFAULT '1', + \`next_run_at\` datetime NULL, + \`last_run_at\` datetime NULL, + \`created_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updated_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`), + INDEX \`schedule_user_id_idx\` (\`user_id\`), + INDEX \`schedule_next_run_at_idx\` (\`next_run_at\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE IF EXISTS \`schedules\``); + await queryRunner.query(`DROP TABLE IF EXISTS \`jobs\``); + } + +} diff --git a/server/yarn.lock b/server/yarn.lock index 9f564f43..cd44c552 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -1288,6 +1288,14 @@ multer "1.4.4-lts.1" tslib "2.4.1" +"@nestjs/schedule@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@nestjs/schedule/-/schedule-3.0.4.tgz#c2a3d96bb2cb7d562349f030823080b8513b34c3" + integrity sha512-uFJpuZsXfpvgx2y7/KrIZW9e1L68TLiwRodZ6+Gc8xqQiHSUzAVn+9F4YMxWFlHITZvvkjWziUFgRNCitDcTZQ== + dependencies: + cron "2.4.3" + uuid "9.0.1" + "@nestjs/schematics@^9.0.0": version "9.0.3" resolved "https://registry.npmjs.org/@nestjs/schematics/-/schematics-9.0.3.tgz" @@ -1737,6 +1745,11 @@ dependencies: "@types/node" "*" +"@types/luxon@~3.3.0": + version "3.3.8" + resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.3.8.tgz#84dbf2d020a9209a272058725e168f21d331a67e" + integrity sha512-jYvz8UMLDgy3a5SkGJne8H7VA7zPV2Lwohjx0V8V31+SqAjNmurWMkk9cQhfvlcnXWudBpK9xPM1n4rljOcHYQ== + "@types/mime@*": version "3.0.1" resolved "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz" @@ -3331,6 +3344,21 @@ create-require@^1.1.0: resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +cron-parser@^4.9.0: + version "4.9.0" + resolved "https://registry.yarnpkg.com/cron-parser/-/cron-parser-4.9.0.tgz#0340694af3e46a0894978c6f52a6dbb5c0f11ad5" + integrity sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q== + dependencies: + luxon "^3.2.1" + +cron@2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/cron/-/cron-2.4.3.tgz#4e43d8d9a6373b8f28d876c4e9a47c14422d8652" + integrity sha512-YBvExkQYF7w0PxyeFLRyr817YVDhGxaCi5/uRRMqa4aWD3IFKRd+uNbpW1VWMdqQy8PZ7CElc+accXJcauPKzQ== + dependencies: + "@types/luxon" "~3.3.0" + luxon "~3.3.0" + cross-fetch@3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" @@ -6206,6 +6234,16 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +luxon@^3.2.1: + version "3.7.2" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.7.2.tgz#d697e48f478553cca187a0f8436aff468e3ba0ba" + integrity sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew== + +luxon@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.3.0.tgz#d73ab5b5d2b49a461c47cedbc7e73309b4805b48" + integrity sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg== + macos-release@^2.5.0: version "2.5.0" resolved "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz" @@ -9273,6 +9311,11 @@ uuid@9.0.0: resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz" integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== +uuid@9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== + v8-compile-cache-lib@^3.0.1: version "3.0.1" resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz"