-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speedups #54
Speedups #54
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.7.7" | ||
__version__ = "0.7.8" |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -66,37 +66,32 @@ async def annotate( | |||||||
for parent in path.parents: | ||||||||
if len(parent.parts) == 0: | ||||||||
parent = Path("ROOT") | ||||||||
directories.add(parent) | ||||||||
directories.add(parent.as_posix()) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conversion of |
||||||||
edges.add((parent.as_posix(), _last.as_posix())) | ||||||||
_last = parent | ||||||||
|
||||||||
for dir in directories: | ||||||||
dir_str = dir.as_posix() | ||||||||
dir_path = dir if dir != Path("ROOT") else Path(".") | ||||||||
document = get_document( | ||||||||
dir_str, cwd, type="directory", ignore_patterns=self.ignore_patterns | ||||||||
) | ||||||||
checksum = hash_str( | ||||||||
"".join( | ||||||||
checksums.get(dir_path / subpath, "") | ||||||||
for subpath in document.split("\n")[1:] | ||||||||
) | ||||||||
) | ||||||||
for source, target in edges: | ||||||||
for id in (source, target): | ||||||||
if id not in graph and id not in directories: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check for |
||||||||
raise RagdaemonError(f"Node {id} not found in graph") | ||||||||
graph.add_edge(source, target, type="hierarchy") | ||||||||
|
||||||||
# Fill-in directory data (same process as get_document for dirs, but more efficient) | ||||||||
for dir in sorted( | ||||||||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Refactoring the sorting of directories to a more concise and readable format improves code maintainability. This change also ensures that 'ROOT' is properly handled as a special case. |
||||||||
directories, key=lambda x: len(x) if x != "ROOT" else 0, reverse=True | ||||||||
): | ||||||||
children = sorted(node for node in graph.successors(dir)) | ||||||||
document = f"{dir}\n" + "\n".join(children) | ||||||||
checksum = hash_str("".join(checksums[Path(child)] for child in children)) | ||||||||
data = { | ||||||||
"id": dir_str, | ||||||||
"id": dir, | ||||||||
"type": "directory", | ||||||||
"ref": dir_str, | ||||||||
"ref": dir, | ||||||||
"document": document, | ||||||||
"checksum": checksum, | ||||||||
} | ||||||||
graph.add_node(dir_str, **data) | ||||||||
checksums[dir] = checksum | ||||||||
|
||||||||
for source, target in edges: | ||||||||
for id in (source, target): | ||||||||
if id not in graph: | ||||||||
raise RagdaemonError(f"Node {id} not found in graph") | ||||||||
graph.add_edge(source, target, type="hierarchy") | ||||||||
checksums[Path(dir)] = checksum | ||||||||
graph.nodes[dir].update(data) | ||||||||
|
||||||||
# Sync with remote DB | ||||||||
ids = list(set(checksums.values())) | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version number has been updated from 0.7.7 to 0.7.8. Please ensure that all related documentation and dependency requirements are also updated accordingly if needed.