From af77d899e68db0d911a7c862b320f7c430c344f5 Mon Sep 17 00:00:00 2001 From: Vargha Csongor Date: Thu, 10 Apr 2025 11:19:33 +0200 Subject: [PATCH] add get managed profiles query --- apps/db-adapter/internal/memgraph/queries.go | 19 +++++++++++++++++++ .../queries/get_managed_profiles.cypher | 3 +++ .../queries/get_profile_admins.cypher | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 apps/db-adapter/internal/memgraph/queries/get_managed_profiles.cypher diff --git a/apps/db-adapter/internal/memgraph/queries.go b/apps/db-adapter/internal/memgraph/queries.go index 2ecd2ba..bbc00ae 100644 --- a/apps/db-adapter/internal/memgraph/queries.go +++ b/apps/db-adapter/internal/memgraph/queries.go @@ -44,6 +44,7 @@ var UpdatePersonByInviteCodeCypherQuery string var GetPersonByGoogleIdCypherQuery string // Requires id parameter. +// // Returns labels(n) AS labels, n AS person // //go:embed queries/soft_delete_person_by_id.cypher @@ -56,22 +57,27 @@ var HardDeletePersonCypherQuery string // Requires id1, id2 parameters. // +// returns relationship +// //go:embed queries/get_relationship.cypher var GetRelationshipCypherQuery string // Requires childId, parentId, childRelationship, parentRelationship parameters. +// // returns relationships // //go:embed queries/create_child_parent_relationships.cypher var CreateChildParentRelationshipCypherQuery string // Requires id1, id2, Relationship1, Relationship1 parameters. +// // return relationships // //go:embed queries/create_sibling_relationship.cypher var CreateSiblingRelationshipCypherQuery string // Requires id1, id2, Relationship1, Relationship1 parameters. +// // return relationships // //go:embed queries/create_spouse_relationship.cypher @@ -89,6 +95,8 @@ var GetFamilyTreeByIdCypherQuery string // Requires id1, id2 parameter. // +// return relationship +// //go:embed queries/create_admin_relationship.cypher var CreateAdminRelationshipCypherQuery string @@ -99,10 +107,21 @@ var DeleteAdminRelationshipCypherQuery string // Requires id1, id2 parameter. // +// return relationship +// //go:embed queries/get_admin_relationship.cypher var GetAdminRelationshipCypherQuery string // Requires id parameter. // +// returns admins +// //go:embed queries/get_profile_admins.cypher var GetProfileAdminsCypherQuery string + +// Requires id parameter. +// +// returns managed +// +//go:embed queries/get_managed_profiles.cypher +var GetManagedProfilesCypherQuery string diff --git a/apps/db-adapter/internal/memgraph/queries/get_managed_profiles.cypher b/apps/db-adapter/internal/memgraph/queries/get_managed_profiles.cypher new file mode 100644 index 0000000..b518a8f --- /dev/null +++ b/apps/db-adapter/internal/memgraph/queries/get_managed_profiles.cypher @@ -0,0 +1,3 @@ +MATCH (a)-[r1:Admin]->(b) +WHERE id(a) = $id +RETURN collect({id: id(b), first_name: b.first_name, last_name: b.last_name, managedSince: r1.added}) as managed; \ No newline at end of file diff --git a/apps/db-adapter/internal/memgraph/queries/get_profile_admins.cypher b/apps/db-adapter/internal/memgraph/queries/get_profile_admins.cypher index 1da33fe..f25ee29 100644 --- a/apps/db-adapter/internal/memgraph/queries/get_profile_admins.cypher +++ b/apps/db-adapter/internal/memgraph/queries/get_profile_admins.cypher @@ -1,3 +1,3 @@ MATCH (a)-[r1:Admin]->(b) WHERE id(b) = $id -RETURN collect(r1) as adminRelationship, collect({id: id(a), first_name: a.first_name, last_name: a.last_name}) as admins; \ No newline at end of file +RETURN collect({id: id(a), first_name: a.first_name, last_name: a.last_name, adminSince: r1.added}) as admins; \ No newline at end of file