-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
add created/updated properties to sync table #8820
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2b4747b
add created/updated to sync table where possible
eelcovdw 1ea21ef
fix job time
eelcovdw b8e0e19
fix job string
eelcovdw 9a06056
clarify
eelcovdw ab4dcd7
Merge branch 'dev' into eelco/sync-table-fixes
eelcovdw 83e2bbb
Merge branch 'dev' into eelco/sync-table-fixes
eelcovdw fc10f66
fix tests
eelcovdw 125e62a
Merge branch 'dev' into eelco/sync-table-fixes
eelcovdw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# stdlib | ||
import datetime | ||
from typing import Any | ||
|
||
# third party | ||
|
@@ -9,6 +10,10 @@ | |
from ....service.code.user_code import UserCode | ||
from ....service.job.job_stash import Job | ||
from ....service.request.request import Request | ||
from ....service.response import SyftError | ||
from ....service.user.user import UserView | ||
from ....types.datetime import DateTime | ||
from ....types.datetime import format_timedelta_human_readable | ||
from ....types.syft_object import SYFT_OBJECT_VERSION_1 | ||
from ....types.syft_object import SyftObject | ||
from ..icons import Icon | ||
|
@@ -101,6 +106,43 @@ def get_status_str(self) -> str: | |
return status.value | ||
return "" # type: ignore | ||
|
||
def get_updated_by(self) -> str: | ||
# TODO replace with centralized SyftObject created/updated by attribute | ||
if isinstance(self.object, Request): | ||
email = self.object.requesting_user_email | ||
if email is not None: | ||
return f"Requested by {email}" | ||
|
||
user_view: UserView | SyftError | None = None | ||
if isinstance(self.object, UserCode): | ||
user_view = self.object.user | ||
|
||
if isinstance(user_view, UserView): | ||
return f"Created by {user_view.email}" | ||
return "" | ||
|
||
def get_updated_delta_str(self) -> str: | ||
# TODO replace with centralized SyftObject created/updated by attribute | ||
if isinstance(self.object, Job): | ||
# NOTE Job is not using DateTime for creation_time, so we need to handle it separately | ||
time_str = self.object.creation_time | ||
if time_str is not None: | ||
t = datetime.datetime.fromisoformat(time_str) | ||
delta = datetime.datetime.now(datetime.timezone.utc) - t | ||
return f"{format_timedelta_human_readable(delta)} ago" | ||
|
||
dt: DateTime | None = None | ||
if isinstance(self.object, Request): | ||
dt = self.object.request_time | ||
if isinstance(self.object, UserCode): | ||
dt = self.object.submit_time | ||
if dt is not None: | ||
delta = DateTime.now().timedelta(dt) | ||
delta_str = format_timedelta_human_readable(delta) | ||
return f"{delta_str} ago" | ||
|
||
return "" | ||
|
||
def to_html(self) -> str: | ||
type_html = TypeLabel(object=self.object).to_html() | ||
|
||
|
@@ -110,10 +152,12 @@ def to_html(self) -> str: | |
copy_text=str(self.object.id.id), max_width=60 | ||
).to_html() | ||
|
||
updated_delta_str = "29m ago" | ||
updated_by = "[email protected]" | ||
updated_delta_str = self.get_updated_delta_str() | ||
updated_by = self.get_updated_by() | ||
status_str = self.get_status_str() | ||
status_seperator = " • " if len(status_str) else "" | ||
status_row = " • ".join( | ||
s for s in [status_str, updated_by, updated_delta_str] if s | ||
) | ||
summary_html = f""" | ||
<div style="display: flex; gap: 8px; justify-content: space-between; width: 100%; overflow: hidden; align-items: center;"> | ||
<div style="display: flex; gap: 8px; justify-content: start; align-items: center;"> | ||
|
@@ -123,7 +167,7 @@ def to_html(self) -> str: | |
</div> | ||
<div style="display: table-row"> | ||
<span class='syncstate-col-footer'> | ||
{status_str}{status_seperator}Updated by {updated_by} {updated_delta_str} | ||
{status_row} | ||
</span> | ||
</div> | ||
""" # noqa: E501 | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this correct? doesnt this just get the user for the current client? What if the current client is the admin, but the DS created this user code?