-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5342 from opsmill/ajtm-12312024-skip-diff-no-changes
skip expensive diff operations when possible
- Loading branch information
Showing
35 changed files
with
841 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Any, Generator | ||
|
||
from infrahub.core.query import Query, QueryType | ||
from infrahub.database import InfrahubDatabase | ||
|
||
|
||
class EnrichedDiffFieldSpecifiersQuery(Query): | ||
name = "enriched_diff_field_specifiers" | ||
type = QueryType.READ | ||
|
||
def __init__(self, diff_id: str, **kwargs: Any) -> None: | ||
super().__init__(**kwargs) | ||
self.diff_id = diff_id | ||
|
||
async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: | ||
self.params["diff_id"] = self.diff_id | ||
query = """ | ||
CALL { | ||
MATCH (root:DiffRoot {uuid: $diff_id})-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_ATTRIBUTE]->(attr:DiffAttribute) | ||
RETURN node.uuid AS node_uuid, attr.name AS field_name | ||
UNION | ||
MATCH (root:DiffRoot {uuid: $diff_id})-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_RELATIONSHIP]->(rel:DiffRelationship) | ||
RETURN node.uuid AS node_uuid, rel.identifier AS field_name | ||
} | ||
""" | ||
self.add_to_query(query=query) | ||
self.return_labels = ["node_uuid", "field_name"] | ||
self.order_by = ["node_uuid", "field_name"] | ||
|
||
def get_node_field_specifier_tuples(self) -> Generator[tuple[str, str], None, None]: | ||
for result in self.get_results(): | ||
node_uuid = result.get_as_str("node_uuid") | ||
field_name = result.get_as_str("field_name") | ||
if node_uuid and field_name: | ||
yield (node_uuid, field_name) |
Oops, something went wrong.