Skip to content

Commit

Permalink
fix: deletion of graph data is now platform agnostic!
Browse files Browse the repository at this point in the history
previouly we forgot to update the data deletion to support newer platform agnostic structure.
  • Loading branch information
amindadgar committed Sep 12, 2024
1 parent ffbb18f commit 0540c44
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ def store_analytics_data(
platform_id=platform_id,
queries_list=queries_list,
remove_memberactivities=remove_memberactivities,
graph_schema=graph_schema,
)
else:
logging.warning("Testing mode enabled! Not saving any data")

def run_operations_transaction(
self, platform_id: str, queries_list: list[Query], remove_memberactivities: bool
self,
platform_id: str,
queries_list: list[Query],
remove_memberactivities: bool,
graph_schema: GraphSchema,
) -> None:
"""
do the deletion and insertion operations inside a transaction
Expand All @@ -119,7 +124,8 @@ def run_operations_transaction(
f"{self.guild_msg} Neo4J platform_id accounts relation will be removed!"
)
delete_relationship_query = self._create_guild_rel_deletion_query(
platform_id=platform_id
platform_id=platform_id,
graph_schema=graph_schema,
)
transaction_queries.append(delete_relationship_query)

Expand All @@ -128,7 +134,10 @@ def run_operations_transaction(
self.neo4j_ops.run_queries_in_batch(transaction_queries, message=self.guild_msg)

def _create_guild_rel_deletion_query(
self, platform_id: str, relation_name: str = "INTERACTED_WITH"
self,
platform_id: str,
graph_schema: GraphSchema,
relation_name: str = "INTERACTED_WITH",
) -> Query:
"""
create a query to delete the relationships
Expand All @@ -148,8 +157,8 @@ def _create_guild_rel_deletion_query(
"""
query_str = f"""
MATCH
(:DiscordAccount)
-[r:{relation_name} {{platformId: '{platform_id}'}}]-(:DiscordAccount)
(:{graph_schema.user_label})
-[r:{graph_schema.interacted_with_rel} {{platformId: '{platform_id}'}}]-(:{graph_schema.user_label})
DETACH DELETE r"""

parameters = {
Expand Down

0 comments on commit 0540c44

Please sign in to comment.