Skip to content
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

Conversation

codingcyclist
Copy link
Contributor

See #280

Copy link
Owner

@gouline gouline left a 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']
Copy link
Owner

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

Comment on lines +115 to +116
average_query_time_ms = None
last_used_at_utc = None
Copy link
Owner

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)

Comment on lines +360 to +361
else:
average_query_time = "n.a."
Copy link
Owner

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.'
Copy link
Owner

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)}"
Copy link
Owner

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?

@gouline gouline changed the base branch from master to 280-additional-card-metadata October 12, 2024 02:55
@gouline gouline merged commit 7904041 into gouline:280-additional-card-metadata Oct 12, 2024
gouline added a commit that referenced this pull request Oct 12, 2024
* 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>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants