|
| 1 | +with |
| 2 | + projectsJson := to_json('[ |
| 3 | + { |
| 4 | + "name": "Glorfindel - Exegetical Facilitator", |
| 5 | + "step": "DiscussingChangeToPlan", |
| 6 | + "mouStart": "2021-07-01", |
| 7 | + "mouEnd": "2024-12-30", |
| 8 | + "estimatedSubmission": "2024-10-01", |
| 9 | + "financialReportPeriod": "Monthly" |
| 10 | + }, |
| 11 | + { |
| 12 | + "name": "Arwen Evenstar Intern", |
| 13 | + "step": "PendingConceptApproval", |
| 14 | + "mouStart": "2022-10-01", |
| 15 | + "mouEnd": "2025-12-30", |
| 16 | + "financialReportPeriod": "Quarterly" |
| 17 | + }, |
| 18 | + { |
| 19 | + "name": "Eomer of Rohan Intern", |
| 20 | + "step": "Active", |
| 21 | + "mouStart": "2022-02-01", |
| 22 | + "mouEnd": "2026-06-30", |
| 23 | + "financialReportPeriod": "Monthly" |
| 24 | + }, |
| 25 | + { |
| 26 | + "name": "Cohort of the Ents", |
| 27 | + "step": "PendingFinancialEndorsement", |
| 28 | + "mouStart": "2022-02-01", |
| 29 | + "mouEnd": "2026-06-30", |
| 30 | + "financialReportPeriod": "Quarterly" |
| 31 | + }, |
| 32 | + { |
| 33 | + "name": "Barliman Butterbur Intern", |
| 34 | + "step": "OnHoldFinanceConfirmation", |
| 35 | + "mouStart": "2018-02-01", |
| 36 | + "mouEnd": "2022-07-30", |
| 37 | + "financialReportPeriod": "Monthly" |
| 38 | + } |
| 39 | + ]'), |
| 40 | + projects := ( |
| 41 | + for project in json_array_unpack(projectsJson) |
| 42 | + union ( |
| 43 | + select ( |
| 44 | + (select InternshipProject filter .name = <str>project['name']) ?? |
| 45 | + (insert InternshipProject { |
| 46 | + name := <str>project['name'], |
| 47 | + step := <str>project['step'], |
| 48 | + mouStart := <cal::local_date>project['mouStart'], |
| 49 | + mouEnd := <cal::local_date>project['mouEnd'], |
| 50 | + estimatedSubmission := <cal::local_date>json_get(project, 'estimatedSubmission'), |
| 51 | + financialReportPeriod := <str>project['financialReportPeriod'] |
| 52 | + }) |
| 53 | + ) |
| 54 | + ) |
| 55 | + ), |
| 56 | + new := (select projects filter .createdAt = datetime_of_statement()) |
| 57 | +select { `Added Internship Projects` := new.name } |
| 58 | +filter count(new) > 0; |
| 59 | + |
| 60 | +# Update all projects to self reference for their context (has to be separate query) |
| 61 | +# https://github.com/edgedb/edgedb/issues/3960 |
| 62 | +with updated := ( |
| 63 | + for project in Project union ( |
| 64 | + update project.projectContext |
| 65 | + set { projects := project } |
| 66 | + ) |
| 67 | +) |
| 68 | +select <str>{}; |
0 commit comments