Skip to content

Commit 515676b

Browse files
authored
Engagements: don't bother checking :Property labels on active properties (#3401)
3739399 Introduced the pattern ```cypher (:Engagement)--(project)-[:name { active: true }]->(name:Property) ``` We have a few engagements in production that have had their projects deleted. But we have not cascaded that delete to the engagement. The deleted project now as the form ```cypher (:Deleted_Project)-[:name { active: true }]->(name:Deleted_Property) ``` These engagements are being referenced in `Language.sponsorStartDate`. Requiring the engagement have a project with a name like ```cypher -[:name]->(:Property) ``` caused the whole engagement to be _not found_, since this required pattern didn't match. The `sponsorStartDate` is synced to DOMO, and that sync expects, as an admin, to be able to read this field. It is throwing now and causing that entire language sync to fail. What have I have here is IMO the fastest fix. It is just removing the constraint that the active project name have a `:Property` label. It is really redundant with the relationship constraint: `-[:name { active: true }]->()` this gives us all the specificity we need. Really it is only [line 973](https://github.com/SeedCompany/cord-api-v3/pull/3401/files#diff-bb8050b85eee2fe8fe8cf88db83676730882a47e87cee4f15be3c8fc24b4ed34L973) that is the problem; but it seems sane to apply the concept everywhere, at least in this file for now. A more holistic solution needs to be worked out for cascading deletes. Deleting a project should delete all engagements, products, etc. I'll leave that for a follow up. Maybe there's something we do or maybe a short term fix until we can migrate to Gel.
1 parent 9cb184b commit 515676b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/components/engagement/engagement.repository.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ export class EngagementRepository extends CommonRepository {
584584
relation('out', '', 'engagement', ACTIVE),
585585
node('engagement'),
586586
relation('out', '', 'status', ACTIVE),
587-
node('sn', 'Property'),
587+
node('sn'),
588588
])
589589
.where({
590590
sn: {
@@ -685,7 +685,7 @@ export class EngagementRepository extends CommonRepository {
685685
.match([
686686
node('language'),
687687
relation('out', '', 'hasExternalFirstScripture', ACTIVE),
688-
node('', 'Property', { value: true }),
688+
node({ value: true }),
689689
])
690690
.return('language')
691691
.first();
@@ -703,7 +703,7 @@ export class EngagementRepository extends CommonRepository {
703703
relation('in', '', 'language', ACTIVE),
704704
node('otherLanguageEngagements', 'LanguageEngagement'),
705705
relation('out', '', 'firstScripture', ACTIVE),
706-
node('', 'Property', { value: true }),
706+
node({ value: true }),
707707
])
708708
.return('otherLanguageEngagements')
709709
.first();
@@ -793,14 +793,14 @@ export const engagementFilters = filter.define(() => EngagementFilters, {
793793
[
794794
node('node'),
795795
relation('out', '', 'startDateOverride', ACTIVE),
796-
node('startDateOverride', 'Property'),
796+
node('startDateOverride'),
797797
],
798798
[
799799
node('node'),
800800
relation('in', '', 'engagement'),
801801
node('project', 'Project'),
802802
relation('out', '', 'mouStart', ACTIVE),
803-
node('mouStart', 'Property'),
803+
node('mouStart'),
804804
],
805805
]);
806806
return coalesce('startDateOverride.value', 'mouStart.value');
@@ -810,14 +810,14 @@ export const engagementFilters = filter.define(() => EngagementFilters, {
810810
[
811811
node('node'),
812812
relation('out', '', 'endDateOverride', ACTIVE),
813-
node('endDateOverride', 'Property'),
813+
node('endDateOverride'),
814814
],
815815
[
816816
node('node'),
817817
relation('in', '', 'engagement'),
818818
node('project', 'Project'),
819819
relation('out', '', 'mouEnd', ACTIVE),
820-
node('mouEnd', 'Property'),
820+
node('mouEnd'),
821821
],
822822
]);
823823
return coalesce('endDateOverride.value', 'mouEnd.value');
@@ -910,7 +910,7 @@ export const engagementSorters = defineSorters(IEngagement, {
910910
.optionalMatch([
911911
node('node'),
912912
relation('out', '', `${field}Override`, ACTIVE),
913-
node('override', 'Property'),
913+
node('override'),
914914
])
915915
.optionalMatch([
916916
node('node'),
@@ -970,26 +970,26 @@ const matchNames = (query: Query) =>
970970
.match([
971971
node('project'),
972972
relation('out', '', 'name', ACTIVE),
973-
node('projectName', 'Property'),
973+
node('projectName'),
974974
])
975975
.optionalMatch([
976976
node('node'),
977977
relation('out', '', 'language'),
978978
node('', 'Language'),
979979
relation('out', '', 'name', ACTIVE),
980-
node('languageName', 'Property'),
980+
node('languageName'),
981981
])
982982
.optionalMatch([
983983
[node('node'), relation('out', '', 'intern'), node('intern', 'User')],
984984
[
985985
node('intern'),
986986
relation('out', '', 'displayFirstName', ACTIVE),
987-
node('dfn', 'Property'),
987+
node('dfn'),
988988
],
989989
[
990990
node('intern'),
991991
relation('out', '', 'displayLastName', ACTIVE),
992-
node('dln', 'Property'),
992+
node('dln'),
993993
],
994994
]);
995995

0 commit comments

Comments
 (0)