Skip to content

Commit

Permalink
PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomedina248 committed Apr 26, 2022
1 parent aca045e commit 962db5f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
15 changes: 8 additions & 7 deletions superset-frontend/src/views/CRUD/data/query/QueryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ function QueryList({ addDangerToast, addSuccessToast }: QueryListProps) {
accessor: QueryObjectColumns.start_time,
Header: t('Time'),
size: 'xl',
Cell: ({ row: { original } }: any) => {
const startTime = parseFloat(original.start_time);
const startMoment = moment.utc(startTime).local();
Cell: ({
row: {
original: { start_time, end_time },
},
}: any) => {
const startMoment = moment.utc(start_time).local();
const formattedStartTimeData = startMoment
.format(DATETIME_WITH_TIME_ZONE)
.split(' ');
Expand All @@ -195,13 +198,11 @@ function QueryList({ addDangerToast, addSuccessToast }: QueryListProps) {
</>
);

return original.end_time ? (
return end_time ? (
<Tooltip
title={t(
'Duration: %s',
moment(
moment.utc(parseFloat(original.end_time) - startTime),
).format(TIME_WITH_MS),
moment(moment.utc(end_time - start_time)).format(TIME_WITH_MS),
)}
placement="bottom"
>
Expand Down
3 changes: 2 additions & 1 deletion superset/queries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from superset.databases.filters import DatabaseFilter
from superset.models.sql_lab import Query
from superset.queries.filters import QueryFilter
from superset.queries.schemas import openapi_spec_methods_override
from superset.queries.schemas import openapi_spec_methods_override, QuerySchema
from superset.views.base_api import BaseSupersetModelRestApi, RelatedFieldFilter
from superset.views.filters import FilterRelatedOwners

Expand Down Expand Up @@ -94,6 +94,7 @@ class QueryRestApi(BaseSupersetModelRestApi):
]
base_filters = [["id", QueryFilter, lambda: []]]
base_order = ("changed_on", "desc")
list_model_schema = QuerySchema()

openapi_spec_tag = "Queries"
openapi_spec_methods = openapi_spec_methods_override
Expand Down
18 changes: 18 additions & 0 deletions superset/queries/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from marshmallow import fields
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema

from superset.models.sql_lab import Query

openapi_spec_methods_override = {
"get": {"get": {"description": "Get query detail information."}},
Expand All @@ -25,3 +29,17 @@
}
},
}


class QuerySchema(SQLAlchemyAutoSchema):
"""
Schema for the ``Query`` model.
"""

start_time = fields.Float(attribute="start_time")
end_time = fields.Float(attribute="end_time")

class Meta: # pylint: disable=too-few-public-methods
model = Query
load_instance = True
include_relationships = True

0 comments on commit 962db5f

Please sign in to comment.