Skip to content

Commit

Permalink
Merge pull request #30 from TogetherCrew/fix/29-graph-data-deletion
Browse files Browse the repository at this point in the history
Fix/29 graph data deletion
  • Loading branch information
amindadgar authored Sep 12, 2024
2 parents ffbb18f + 4f38cd3 commit 3c690f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="tc-analyzer-lib",
version="1.4.7",
version="1.4.8",
author="Mohammad Amin Dadgar, TogetherCrew",
maintainer="Mohammad Amin Dadgar",
maintainer_email="dadgaramin96@gmail.com",
Expand Down
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 3c690f4

Please sign in to comment.