Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import time
from neo4j import GraphDatabase

uri = "bolt://localhost:7687"
user = "neo4j"
password = "your_password"

driver = GraphDatabase.driver(uri, auth=(user, password))


def run_query():
with driver.session() as session:
start_time = time.time()
session.run("MATCH (s:Standard)-[:RELATED_TO]->(f:Framework) RETURN s, f;")
end_time = time.time()
print(
f"Execution Time BEFORE Optimization: {(end_time - start_time) * 1000:.2f} ms"
)


run_query()
driver.close()


# modify banchmark.py
def run_optimized_query():
with driver.session() as session:
start_time = time.time()
session.run(
"""
MATCH (s:Standard)-[:RELATED_TO]->(f:Framework)
USING INDEX s:Standard(name)
RETURN s, f LIMIT 1000;
"""
)
end_time = time.time()
print(
f"Execution Time AFTER Optimization: {(end_time - start_time) * 1000:.2f} ms"
)


run_optimized_query()
15 changes: 15 additions & 0 deletions .github/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Access the variables
database_url = os.getenv("DATABASE_URL")
secret_key = os.getenv("SECRET_KEY")
debug_mode = os.getenv("DEBUG")

# Print values (for debugging)
print(f"Database URL: {database_url}")
print(f"Secret Key: {secret_key}")
print(f"Debug Mode: {debug_mode}")
22 changes: 22 additions & 0 deletions .github/connect_neo4j.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
from neo4j import GraphDatabase
from dotenv import load_dotenv

# Neo4j connection details
uri = "bolt://localhost:7687"
user = "neo4j"
password = "Hardik123@"

# Connect to Neo4j
driver = GraphDatabase.driver(uri, auth=(user, password))


def test_connection():
with driver.session() as session:
result = session.run("RETURN 'Connected to Neo4j' AS message")
for record in result:
print(record["message"])


test_connection()
driver.close()
1 change: 1 addition & 0 deletions .github/neo4j.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dbms.security.procedures.unrestricted=apoc.*
22 changes: 22 additions & 0 deletions .github/query_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from neo4j_connection import db # type: ignore

# Optimized query for performance
query = """
PROFILE MATCH (s:Standard)-[:RELATED_TO]->(f:Framework)
USING INDEX s:Standard(name)
RETURN s, f LIMIT 1000;
"""

# Execute and print results
result = db.run_query(query)
for record in result:
print(record)

db.close()
# modify query fie
query = """
CALL apoc.cypher.runTimeboxed(
'MATCH (s:Standard)-[:RELATED_TO]->(f:Framework) RETURN s, f',
{timeout: 5000}
);
"""
16 changes: 16 additions & 0 deletions .github/setup_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from neo4j_connection import db # type: ignore

# Queries to create nodes, relationships, and indexes
queries = [
"CREATE (:User {name: 'Alice'})-[:FRIENDS_WITH]->(:User {name: 'Bob'});",
"CREATE (:User {name: 'Charlie'})-[:FRIENDS_WITH]->(:User {name: 'Dave'});",
"CREATE INDEX FOR (s:Standard) ON (s.name);",
"CREATE INDEX FOR (f:Framework) ON (f.name);",
]

# Execute each query
for query in queries:
db.run_query(query)
print(f"Executed: {query}")

db.close()
20 changes: 20 additions & 0 deletions .github/test_connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from neo4j import GraphDatabase

# Connection details
uri = "bolt://localhost:7687"
username = "neo4j"
password = "your_password"

# Connect to Neo4j
driver = GraphDatabase.driver(uri, auth=(username, password))


# Function to test connection
def test_connection():
with driver.session() as session:
result = session.run("RETURN 'Connection successful' AS message")
print(result.single()["message"])


if __name__ == "_main_":
test_connection()
2 changes: 1 addition & 1 deletion application/utils/spreadsheet_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def update_cre_in_links(


def parse_hierarchical_export_format(
cre_file: List[Dict[str, str]]
cre_file: List[Dict[str, str]],
) -> Dict[str, List[defs.Document]]:
"""parses the main OpenCRE csv and creates a list of standards in it

Expand Down
2 changes: 1 addition & 1 deletion migrations/versions/7a17989aa1e3_first_migration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""First Migration

Revision ID: 7a17989aa1e3
Revises:
Revises:
Create Date: 2021-08-31 19:23:49.227719

"""
Expand Down