Skip to content

Commit

Permalink
Use system__activity instead of i__looker
Browse files Browse the repository at this point in the history
  • Loading branch information
rbob86 committed Apr 10, 2024
1 parent cbf7eb1 commit b57ae68
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion henry/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.3.2"
33 changes: 20 additions & 13 deletions henry/commands/pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ def check_db_connections(self):
for connection in db_connections:
assert connection.dialect
assert isinstance(connection.name, str)
resp = self.sdk.test_connection(
connection.name,
models.DelimSequence(connection.dialect.connection_tests),
)
results = list(filter(lambda r: r.status == "error", resp))
errors = [f"- {fill(cast(str, e.message), width=100)}" for e in results]
try:
resp = self.sdk.test_connection(
connection.name,
models.DelimSequence(connection.dialect.connection_tests),
)
results = list(filter(lambda r: r.status == "error", resp))
errors = [f"- {fill(cast(str, e.message), width=100)}" for e in results]
except SDKError:
results = []
errors = ["API JSONDecode Error"]
resp = self.sdk.run_inline_query(
"json",
models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["history.query_run_count"],
filters={"history.connection_name": connection.name},
Expand All @@ -76,7 +80,7 @@ def check_dashboard_performance(self):
"30 seconds in the last 7 days"
)
request = models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["dashboard.title, query.count"],
filters={
Expand All @@ -99,7 +103,7 @@ def check_dashboard_errors(self):
"\bTest 3/6: Checking for dashboards with erroring queries in the last 7 days" # noqa: B950
)
request = models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["dashboard.title", "history.query_run_count"],
filters={
Expand All @@ -120,7 +124,7 @@ def check_explore_performance(self):
"""Prints a list of the slowest running explores."""
print("\bTest 4/6: Checking for the slowest explores in the past 7 days")
request = models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["query.model", "query.view", "history.average_runtime"],
filters={
Expand Down Expand Up @@ -148,7 +152,7 @@ def check_schedule_failures(self):
"""Prints a list of schedules that have failed in the past 7 days."""
print("\bTest 5/6: Checking for failing schedules")
request = models.WriteQuery(
model="i__looker",
model="system__activity",
view="scheduled_plan",
fields=["scheduled_job.name", "scheduled_job.count"],
filters={
Expand All @@ -166,6 +170,9 @@ def check_schedule_failures(self):
def check_legacy_features(self):
"""Prints a list of enabled legacy features."""
print("\bTest 6/6: Checking for enabled legacy features")
lf = list(filter(lambda f: f.enabled, self.sdk.all_legacy_features()))
legacy_features = [{"Feature": cast(str, f.name)} for f in lf]
try:
lf = list(filter(lambda f: f.enabled, self.sdk.all_legacy_features()))
legacy_features = [{"Feature": cast(str, f.name)} for f in lf]
except SDKError:
legacy_features = [["Unable to pull legacy features due to SDK error"]]
self._tabularize_and_print(legacy_features)
14 changes: 7 additions & 7 deletions henry/modules/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ def get_used_models(self) -> Dict[str, int]:
resp = self.sdk.run_inline_query(
"json",
models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["history.query_run_count", "query.model"],
filters={
"history.created_date": self.timeframe,
"query.model": "-system^_^_activity, -i^_^_looker",
"history.query_run_count": ">0",
"user.dev_mode": "No",
"user.dev_branch_name": "NULL",
},
limit="5000",
),
Expand Down Expand Up @@ -177,7 +177,7 @@ def get_used_explores(
resp = self.sdk.run_inline_query(
"json",
models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=["query.view", "history.query_run_count"],
filters={
Expand Down Expand Up @@ -225,13 +225,13 @@ def get_used_explore_fields(
resp = self.sdk.run_inline_query(
"json",
models.WriteQuery(
model="i__looker",
model="system__activity",
view="history",
fields=[
"query.model",
"query.view",
"query.formatted_fields",
"query.formatted_filters",
"query.filters",
"history.query_run_count",
],
filters={
Expand Down Expand Up @@ -261,9 +261,9 @@ def get_used_explore_fields(
# A field used as a filter in a query is not listed in
# query.formatted_fields BUT if the field is used as both a filter
# and a dimension/measure, it's listed in both query.formatted_fields
# and query.formatted_filters. The recorded variable keeps track of
# and query.filters. The recorded variable keeps track of
# this, so that no double counting occurs.
filters = row["query.formatted_filters"]
filters = row["query.filters"]
if filters:
parsed_filters = re.findall(r"(\w+\.\w+)+", filters)
for f in parsed_filters:
Expand Down

0 comments on commit b57ae68

Please sign in to comment.