mirror of
https://github.com/valitydev/redash.git
synced 2024-11-08 09:53:59 +00:00
Fix: Queries#all_queries was sometimes returning wrong number of queries.
This commit is contained in:
parent
18d9b2eec9
commit
ada8a1255b
@ -848,13 +848,16 @@ class Query(ChangeTrackingMixin, TimestampMixin, BelongsToOrgMixin, db.Model):
|
||||
|
||||
@classmethod
|
||||
def all_queries(cls, group_ids, user_id=None, drafts=False):
|
||||
query_ids = (db.session.query(distinct(cls.id))
|
||||
.join(DataSourceGroup, Query.data_source_id == DataSourceGroup.data_source_id)
|
||||
.filter(Query.is_archived == False)
|
||||
.filter(DataSourceGroup.group_id.in_(group_ids)))
|
||||
|
||||
q = (cls.query
|
||||
.options(joinedload(Query.user),
|
||||
joinedload(Query.latest_query_data).load_only('runtime', 'retrieved_at'))
|
||||
.join(DataSourceGroup, Query.data_source_id == DataSourceGroup.data_source_id)
|
||||
.filter(Query.is_archived == False)
|
||||
.filter(DataSourceGroup.group_id.in_(group_ids))
|
||||
.order_by(Query.created_at.desc()))
|
||||
.options(joinedload(Query.user),
|
||||
joinedload(Query.latest_query_data).load_only('runtime', 'retrieved_at'))
|
||||
.filter(cls.id.in_(query_ids))
|
||||
.order_by(Query.created_at.desc()))
|
||||
|
||||
if not drafts:
|
||||
q = q.filter(or_(Query.is_draft == False, Query.user_id == user_id))
|
||||
|
Loading…
Reference in New Issue
Block a user