Make sure only 20 dashboards/queries returned in recent call.

This commit is contained in:
Arik Fraimovich 2015-09-20 11:12:44 +03:00
parent 5f656f3868
commit 46f1478e0d
2 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ from flask import request
from flask.ext.restful import abort
from flask_login import current_user
from funcy import distinct
from funcy import distinct, take
from itertools import chain
from redash import models
@ -19,7 +19,7 @@ class DashboardRecentAPI(BaseResource):
if len(recent) < 10:
global_recent = [d.to_dict() for d in models.Dashboard.recent()]
return distinct(chain(recent, global_recent), key=lambda d: d['id'])
return take(20, distinct(chain(recent, global_recent), key=lambda d: d['id']))
class DashboardListAPI(BaseResource):

View File

@ -3,7 +3,7 @@ from flask.ext.restful import abort
from flask_login import current_user, login_required
import sqlparse
from funcy import distinct
from funcy import distinct, take
from itertools import chain
from redash import models
@ -56,7 +56,7 @@ class QueryRecentAPI(BaseResource):
if len(recent) < 10:
global_recent = [d.to_dict() for d in models.Query.recent()]
return distinct(chain(recent, global_recent), key=lambda d: d['id'])
return take(20, distinct(chain(recent, global_recent), key=lambda d: d['id']))
class QueryListAPI(BaseResource):