-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Additional metadata to understand "usability" of a card #281
Additional metadata to understand "usability" of a card #281
Conversation
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.
You haven't run the linter/formatter, please do this before pushing any commits
@@ -128,6 +130,8 @@ def extract_exposures( | |||
result = self.__extract_card_exposures(ctx, card=entity) | |||
depends.update(result["depends"]) | |||
native_query = result["native_query"] | |||
average_query_time_ms = entity.get('average_query_time') | |||
last_used_at_utc = entity['last_used_at'] |
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.
Should be an optional get()
as well
average_query_time_ms = None | ||
last_used_at_utc = None |
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.
Since you're retrieving them as-is from Metabase, keep the naming identical (i.e. no _ms
and _at_utc
)
else: | ||
average_query_time = "n.a." |
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.
If not provided, shouldn't be included at all
@@ -360,6 +373,10 @@ def __format_exposure( | |||
"email": creator_email, | |||
}, | |||
"depends_on": list(depends_on), | |||
"meta": { | |||
"avg_query_time": average_query_time, | |||
"last_used_at_utc": last_used_at_utc or 'n.a.' |
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.
Same here, if not provided, shouldn't be included at all (build up meta
conditionally as a dictionary variable and only set it when not empty)
@@ -346,6 +354,11 @@ def __format_exposure( | |||
+ f"Created On: __{created_at}__" | |||
) | |||
|
|||
if average_query_time_ms: | |||
average_query_time_s = average_query_time_ms // 1000 | |||
average_query_time = f"{int(average_query_time_s // 60)}:{str(int(average_query_time_s % 60)).zfill(2)}" |
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.
If the original value is in milliseconds (i.e. 1000th), why are you zfill'ing with only 2 and not 3?
* Feat: avg query time + last used at timestamp (#281) * Query average time and last usage metadata --------- Co-authored-by: Simon Rosenberger (Bumm) <41942954+codingcyclist@users.noreply.github.com>
See #280