Skip to content

Commit

Permalink
removed unneeded asc func
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Chubatiuk committed Jan 11, 2024
1 parent d3813d4 commit 8d118f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions redash/handlers/dashboards.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import request, url_for
from flask_restful import abort
from funcy import partial, project
from sqlalchemy import asc, desc, func
from sqlalchemy import desc, func
from sqlalchemy.orm.exc import StaleDataError

from redash import models
Expand All @@ -24,7 +24,7 @@
# Ordering map for relationships
order_map = {
"name": [
asc(func.lower(models.Dashboard.name)),
func.lower(models.Dashboard.name),
models.Dashboard.created_at,
models.Dashboard.slug,
],
Expand All @@ -35,7 +35,7 @@
],
"created_at": [
func.lower(models.Dashboard.name),
asc(models.Dashboard.created_at),
models.Dashboard.created_at,
models.Dashboard.slug,
],
"-created_at": [
Expand Down
26 changes: 13 additions & 13 deletions redash/handlers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask_login import login_required
from flask_restful import abort
from funcy import partial
from sqlalchemy import asc, desc
from sqlalchemy import desc, func
from sqlalchemy.orm.exc import StaleDataError

from redash import models, settings
Expand Down Expand Up @@ -33,18 +33,18 @@

# Ordering map for relationships
order_map = {
"name": [asc("lowercase_name")],
"-name": [desc("lowercase_name")],
"created_at": [asc("created_at")],
"-created_at": [desc("created_at")],
"schedule": [asc("interval")],
"-schedule": [desc("interval")],
"runtime": [asc("query_results.runtime")],
"-runtime": [desc("query_results.runtime")],
"executed_at": [asc("query_results-retrieved_at")],
"-executed_at": [desc("query_results-retrieved_at")],
"created_by": [asc("users.name")],
"-created_by": [desc("users.name")],
"name": [func.lower(models.Query.name)],
"-name": [desc(func.lower(models.Query.name))],
"created_at": [models.Query.created_at],
"-created_at": [desc(models.Query.created_at)],
"schedule": [models.Query.interval],
"-schedule": [desc(models.Query.interval)],
"runtime": [models.QueryResult.runtime],
"-runtime": [desc(models.QueryResult.runtime)],
"executed_at": [models.QueryResult.retrieved_at],
"-executed_at": [desc(models.QueryResult.retrieved_at)],
"created_by": [models.User.name],
"-created_by": [desc(models.User.name)],
}

order_results = partial(_order_results, default_order=order_map["-created_at"], allowed_orders=order_map)
Expand Down

0 comments on commit 8d118f2

Please sign in to comment.