Skip to content

Commit 5fff1d7

Browse files
authored
[EdgeDB] Add seed data for Internship Projects (#3083)
1 parent df8a7cb commit 5fff1d7

File tree

4 files changed

+90
-2
lines changed

4 files changed

+90
-2
lines changed

dbschema/seeds/006.translation-projects.edgeql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ with
5656
)
5757
),
5858
new := (select projects filter .createdAt = datetime_of_statement())
59-
select { `Added Projects` := new.name }
59+
select { `Added Translation Projects` := new.name }
6060
filter count(new) > 0;
6161

6262
# Update all projects to self reference for their context (has to be separate query)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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>{};

dbschema/seeds/008.project-members.edgeql

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ with
1919
{
2020
"project": "South Downs",
2121
"members": ["Bilbo", "Peregrin"]
22+
},
23+
{
24+
"project": "Glorfindel - Exegetical Facilitator",
25+
"members": ["Aragorn", "Samwise"]
26+
},
27+
{
28+
"project": "Arwen Evenstar Intern",
29+
"members": ["Gandalf", "Frodo"]
30+
},
31+
{
32+
"project": "Eomer of Rohan Intern",
33+
"members": ["Bilbo"]
34+
},
35+
{
36+
"project": "Cohort of the Ents",
37+
"members": ["Gandalf", "Meriadoc", "Peregrin"]
38+
},
39+
{
40+
"project": "Barliman Butterbur Intern",
41+
"members": ["Gandalf", "Meriadoc", "Peregrin", "Bilbo", "Frodo", "Samwise"]
2242
}
2343
]'),
2444
newMembers := (
@@ -28,7 +48,7 @@ with
2848
union (
2949
with
3050
existingUser := assert_single((select User filter .realFirstName = <str>member)),
31-
existingProject := assert_single((select TranslationProject filter .name = <str>projectMembers['project'])),
51+
existingProject := assert_single((select Project filter .name = <str>projectMembers['project'])),
3252
select (
3353
(select Project::Member filter .user = existingUser and .project = existingProject) ??
3454
(insert Project::Member {
File renamed without changes.

0 commit comments

Comments
 (0)