-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: list view for query history #11574
Conversation
edd5f5b
to
1b8bc5d
Compare
Codecov Report
@@ Coverage Diff @@
## master #11574 +/- ##
==========================================
- Coverage 62.87% 60.03% -2.85%
==========================================
Files 887 843 -44
Lines 42920 41316 -1604
Branches 3989 3722 -267
==========================================
- Hits 26987 24803 -2184
- Misses 15754 16348 +594
+ Partials 179 165 -14
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
e7948f0
to
ccc1bbd
Compare
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.
a small nitpick. LGTM
<rect x="10" y="8" width="8" height="2" rx="1" transform="rotate(90 10 8)" fill="#B2B2B2"/> | ||
<rect x="13" y="8" width="8" height="2" rx="1" transform="rotate(90 13 8)" fill="#666666"/> | ||
<rect x="16" y="8" width="8" height="2" rx="1" transform="rotate(90 16 8)" fill="#323232"/> |
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 these colors be hard coded here?
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.
I don't think we can have multiple colors using the currentColor
approach used in other files.
@@ -97,15 +97,15 @@ describe('AnnotationList', () => { | |||
|
|||
it('fetches annotation layer', () => { | |||
const callsQ = fetchMock.calls(/annotation_layer\/1/); | |||
expect(callsQ).toHaveLength(3); | |||
expect(callsQ[2][0]).toMatchInlineSnapshot( | |||
expect(callsQ).toHaveLength(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.
why did this change the AnnotationList tests? Seems a bit unexpected to me
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.
It's this line https://github.com/apache/incubator-superset/pull/11574/files#diff-9c9be0048f0d0d4f1bd547faad9f8732fe5a12df6fc185190681914251131cc9R61 that removed an unecessary network request
@@ -0,0 +1,97 @@ | |||
/** |
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.
thanks for the test!
[], | ||
); | ||
|
||
const filters: Filters = useMemo(() => [], []); |
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.
why do we need useMemo
for this? if it's always a function that returns an array, why not make that a const outside of the render function and them use it in TopAlignedListView
?
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.
It's currently an empty array at the moment, but will soon be an array with dynamic values as it is in other list views, eg https://github.com/preset-io/incubator-superset/blob/091432ea8ea4ddd7281eaf41c261f006fe99b352/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx#L319
@@ -332,6 +332,7 @@ def _try_json_readsha( # pylint: disable=unused-argument | |||
# a custom security config could potentially give access to setting filters on | |||
# tables that users do not have access to. | |||
"ROW_LEVEL_SECURITY": False, | |||
"SIP_34_QUERY_SEARCH_UI": False, |
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.
thanks for using a feature flag!
"common": common_bootstrap_payload(), | ||
} | ||
return self.render_template( | ||
"superset/crud_views.html", |
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 the base superset view always return the crud_views template? That seems a bit odd to me.
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.
As state below this is repeating another pattern found in other list views. This method is cloned over from SupersetModelView
(https://github.com/preset-io/incubator-superset/blob/690689c5caed2becf3a1b6a322fb882df082022a/superset/views/base.py#L338) since inheriting from SupersetModelView
in the Superset
class was causing an error.
): | ||
return redirect("/superset/sqllab#search", code=307) | ||
|
||
return super().render_app_template() |
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.
instead of this being a super
function, maybe it should just return a render_crud_views_template
that lives in the crud directory?
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.
Sure we could make this a function instead of a method on the base class. I don't see any big advantages there. We've been using this pattern for all other FAB CRUD view replacements, eg https://github.com/preset-io/incubator-superset/blob/091432ea8ea4ddd7281eaf41c261f006fe99b352/superset/views/database/views.py#L104
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 this is of concern we can open an issue to clean up how the app templates are rendered for these CRUD view replacements. There are a few other follow up PRs that are waiting for this to be merged so I'm hesitant in adding "refactor all routing/template logic for crud views" to the current scope.
UX / UI question, is there any specific reason why SQL column width is reduced? Our users are looking on sql first while searching for smth & I find it beneficial to keep for space to the query itself |
@bkyryliuk no specific reason. The designs call for all the other cells to fit on a single line. Your suggestion makes sense though, how does this look? |
Thats nicer, thanks ! |
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.
lgtm with one other comment (not required to address)
const startUtc = new Date( | ||
Date.UTC( | ||
startDate.getFullYear(), | ||
startDate.getMonth(), | ||
startDate.getDate(), | ||
startDate.getHours(), | ||
startDate.getMinutes(), | ||
startDate.getSeconds(), | ||
startDate.getMilliseconds(), | ||
), | ||
); |
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.
this feels way too complicated, but maybe this is the only way to do it? Perhaps we can use a library like moment
to convert into UTC?
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.
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 the backend already returns timestamps as UNIX epoch time, you can probably get by without doing special treatment for timezones:
diff --git a/superset-frontend/src/views/CRUD/data/query/QueryList.tsx b/superset-frontend/src/views/CRUD/data/query/QueryList.tsx
index 220c1a14e..0a223a536 100644
--- a/superset-frontend/src/views/CRUD/data/query/QueryList.tsx
+++ b/superset-frontend/src/views/CRUD/data/query/QueryList.tsx
@@ -194,20 +194,7 @@ function QueryList({ addDangerToast, addSuccessToast }: QueryListProps) {
original: { start_time, end_time },
},
}: any) => {
- const startDate = new Date(start_time);
- const startUtc = new Date(
- Date.UTC(
- startDate.getFullYear(),
- startDate.getMonth(),
- startDate.getDate(),
- startDate.getHours(),
- startDate.getMinutes(),
- startDate.getSeconds(),
- startDate.getMilliseconds(),
- ),
- );
- const startMoment = moment(startUtc);
- const formattedStartTimeData = startMoment
+ const formattedStartTimeData = moment(start_time)
.format(DATETIME_WITH_TIME_ZONE)
.split(' ');
@@ -217,35 +204,18 @@ function QueryList({ addDangerToast, addSuccessToast }: QueryListProps) {
{formattedStartTimeData[1]}
</>
);
- if (!end_time) {
- return formattedStartTime;
- }
-
- const endDate = new Date(end_time);
- const endUtc = new Date(
- Date.UTC(
- endDate.getFullYear(),
- endDate.getMonth(),
- endDate.getDate(),
- endDate.getHours(),
- endDate.getMinutes(),
- endDate.getSeconds(),
- endDate.getMilliseconds(),
- ),
- );
-
- return (
+ return end_time ? (
<Tooltip
title={t(
'Duration: %s',
- moment
- .utc(moment(endUtc).diff(startMoment))
- .format(TIME_WITH_MS),
+ moment.utc(end_time - start_time).format(TIME_WITH_MS),
)}
placement="bottom"
>
<span>{formattedStartTime}</span>
</Tooltip>
+ ) : (
+ formattedStartTime
);
},
},
I'm also not sure how useful is the timezone to the users here. Most people would assume it is local time if no timezone is specified.
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.
To be clear this logic currently exists elsewhere in the list views (eg, https://github.com/preset-io/incubator-superset/blob/542d2e3b06095ff90bba382bf0b05adc8e62f91a/superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx#L290)
The problem, as I understand it, is the these times are being stored without timestamps. So to avoid confusion, we assume the server times are in UTC as is common for most production servers. So any time that is sent from the server without a time zone is assumed to be in utc, so we must parse it as such to display correct results on the client. In your example @ktmud this was done locally where your dev server and db are running on your local timezone. We have had several issues with this before (things looking correct in local but wrong when they're on prod) and I believe this is the agreed upon safest approach.
I did manage to reduce this logic to only use moment though.
cc @graceguo-supercat @riahk @dpgaspar since they're a little more familiar with the problem than I am
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.
As far as time zone info being useful or not, the goal of this PR is to reskin the previous view. Since time zone info existed in the previous view I think we should keep it for now and raise this issue separately where we can achieve consensus on this decision.
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.
The backend returns the timestamp as unix epoch time, which by definition is timezone-less. Maybe different API endpoints handle it differently? @villebro have you done anything in this regard before, too?
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.
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.
Yeah, using moment.utc(..).local(..)
is probably safer in case the backend returns ISO timestamp strings without timezones.
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.
@ktmud actually, you are correct. These are unix epochs, which are always in utc (or # seconds from midnight utc...1970). The problem I outlined above only applies to text-based datetimes. I've updated this logic to use your suggestions. Thanks for catching this!
It looks like the minimal screen width this view can support is about 1420 (anything less than that would cause a horizontal scroll bar). According to public stats, only about 20% desktop users in the US have a higher resolution than that (probably lower worldwide). Can we use more dynamic column width and make sure this table also look good on smaller screens? |
ddc359e
to
3627dda
Compare
@ktmud It does look like the previous version did support a smaller screen width without scroll. I managed to adjust the column widths a bit but was unable to get it to exactly match previous behavior. The previous version was using a smaller font-size (12px vs 14px), smaller header font, and no sorting on the columns, so naturally there was more room available. All our other list views also suffer from this issue, particularly the ones with lots of columns to display. If this is of concern we should address this issue in the context of all our list views as the goal here is to have unified experience. We could change font-size based on screen width is an idea that immediately comes to mind. |
b731870
to
6020af4
Compare
IMO the check mark / "x" is a downgrade from the pills as an indicator of success state from UX point of view. The larger surface area of pills makes for a more visible status indicator. Now the rows sort of blend in. |
SUMMARY
/superset/sqllab#search
) with a new list view/superset/sqllab/history
and sets up redirectsSIP_34_QUERY_SEARCH_UI
until feature completeBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
before:
After:
TEST PLAN
/superset/sqllab#search
-> redirects to/superset/sqllab/search
ADDITIONAL INFORMATION
SIP_34_QUERY_SEARCH_UI
)