Skip to content

Commit

Permalink
feat: updated existing codebase design
Browse files Browse the repository at this point in the history
  • Loading branch information
JayGhiya committed Oct 6, 2024
1 parent f28c07a commit 9207b65
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 16 deletions.
61 changes: 61 additions & 0 deletions scripts/export_data_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from neo4j import GraphDatabase
import json

# Replace these credentials with your Neo4j database info
uri = "bolt://localhost:7687"
username = "neo4j"
password = "Ke7Rk7jB:Jn2Uz:"

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

def export_graph_to_json():
with driver.session() as session:
# Query for all nodes and their properties
nodes_query = """
MATCH (n)
RETURN elementId(n) as id, labels(n) as labels, properties(n) as properties
"""
nodes_result = session.run(nodes_query)

# Query for all relationships and their properties
relationships_query = """
MATCH (start)-[r:CONTAINS]->(end)
RETURN id(r) as id, type(r) as type, properties(r) as properties,
elementId(start) as startNode, elementId(end) as endNode
"""
relationships_result = session.run(relationships_query)

# Build the JSON structure
data = {"nodes": [], "relationships": []}

# Process nodes
for record in nodes_result:
node = {
"id": record["id"],
"labels": record["labels"],
"properties": record["properties"]
}
data["nodes"].append(node)

# Process relationships
for record in relationships_result:
relationship = {
"id": record["id"],
"type": record["type"],
"properties": record["properties"],
"startNode": record["startNode"],
"endNode": record["endNode"]
}
data["relationships"].append(relationship)

# Output to JSON file
with open("textgrad_graph_export.json", "w") as f:
json.dump(data, f, indent=4)

print("Export completed. JSON saved as textgrad_graph_export.json.")

# Run the export
export_graph_to_json()

# Close the driver connection
driver.close()
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,42 @@ Checkbox {

#history-placeholder {
height: 1fr;
}

ExistingCodebaseList {
align: center middle;
}

ExistingCodebaseList > Container {
width: 40%;
height: 40%;
border: thick $primary;
background: $surface;
padding: 1 2;
}

#existing-codebases-title {
background: $primary;
color: $text;
padding: 1;
text-align: center;
margin-bottom: 1;
content-align: center middle;
align: center middle;
width: 100%;
}

#list-container {
height: 100%;
border: solid $primary;
padding: 1;
}

ListView {
height: 100%;
border: none;
}

#async-list {
height: 1fr;
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@

from textual.screen import ModalScreen
from textual.app import ComposeResult
from textual.widgets import Button, Label, DirectoryTree
from textual.widgets import Button, Label, ListView, ListItem, Header, Footer
from textual.containers import Container
from processing.query_engine_process import QueryEngineProcess
import os
from widgets.json_directory_tree import JSONDirectoryTree
from textual.widgets import ListView, ListItem
from textual.binding import Binding

class ExistingCodebaseList(ModalScreen):

BINDINGS = [
Binding("ctrl+q", "request_quit", "Quit",show=True,priority=True),
]
Binding("ctrl+q", "request_quit", "Quit", show=True, priority=True),
]

def action_request_quit(self) -> None:
self.app.pop_screen()

def __init__(self, query_engine_process: QueryEngineProcess, **kwargs):
super().__init__(**kwargs)
self.query_engine_process = query_engine_process

def compose(self) -> ComposeResult:
yield Container(
ListView(id="async-list"),
id="list-container"
)
yield Header(show_clock=True)
yield Container(
Label("Existing Codebases", id="existing-codebases-title"),
ListView(id="async-list"),
id="list-container"
)
yield Footer()

def action_request_quit(self) -> None:
self.app.pop_screen()

async def on_mount(self) -> None:
await self.load_data()
Expand All @@ -35,5 +35,4 @@ async def load_data(self) -> None:
codebases_list: list = await self.query_engine_process.load_existing_codebases()
list_items = [ListItem(Label(codebase)) for codebase in codebases_list]
list_view.extend(list_items)



0 comments on commit 9207b65

Please sign in to comment.