Skip to content

Commit

Permalink
Fix select stmt in webapps/reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Jul 19, 2023
1 parent d2837c6 commit 00a600e
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 304 deletions.
60 changes: 33 additions & 27 deletions lib/galaxy/webapps/reports/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,47 @@ def history_and_dataset_per_user(self, trans, **kwd):
# from history h, galaxy_user u
# where h.user_id = u.id and h.deleted='f'
# group by email order by email desc
histories = sa.select(
(
histories = (
sa.select(
sa.func.count(galaxy.model.History.table.c.id).label("history"),
galaxy.model.User.table.c.email.label("email"),
),
from_obj=[sa.outerjoin(galaxy.model.History.table, galaxy.model.User.table)],
whereclause=and_(
galaxy.model.History.table.c.user_id == galaxy.model.User.table.c.id,
galaxy.model.History.table.c.deleted == "f",
),
group_by=["email"],
order_by=[sa.desc("email"), "history"],
)
.select_from(sa.outerjoin(galaxy.model.History.table, galaxy.model.User.table))
.where(
and_(
galaxy.model.History.table.c.user_id == galaxy.model.User.table.c.id,
galaxy.model.History.table.c.deleted == "f",
)
)
.group_by("email")
.order_by(sa.desc("email"), "history")
)

# select u.email, count(d.id)
# from galaxy_user u, dataset d, history_dataset_association hd,history h
# where d.id=hd.dataset_id and h.id=hd.history_id and u.id = h.user_id and h.deleted='f'
# group by u.email;
datasets = sa.select(
(
datasets = (
sa.select(
sa.func.count(galaxy.model.Dataset.table.c.id).label("dataset"),
sa.func.sum(galaxy.model.Dataset.table.c.total_size).label("size"),
galaxy.model.User.table.c.email.label("email"),
),
from_obj=[
)
.select_from(
galaxy.model.User.table,
galaxy.model.Dataset.table,
galaxy.model.HistoryDatasetAssociation.table,
galaxy.model.History.table,
],
whereclause=and_(
galaxy.model.Dataset.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.dataset_id,
galaxy.model.History.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.history_id,
galaxy.model.History.table.c.user_id == galaxy.model.User.table.c.id,
galaxy.model.History.table.c.deleted == "f",
),
group_by=["email"],
)
.where(
and_(
galaxy.model.Dataset.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.dataset_id,
galaxy.model.History.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.history_id,
galaxy.model.History.table.c.user_id == galaxy.model.User.table.c.id,
galaxy.model.History.table.c.deleted == "f",
)
)
.group_by("email")
)

# execute requests, replace None fields by "Unknown"
Expand Down Expand Up @@ -178,11 +182,13 @@ def history_and_dataset_type(self, trans, **kwd):
galaxy.model.Dataset.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.dataset_id,
galaxy.model.History.table.c.id == galaxy.model.HistoryDatasetAssociation.table.c.history_id,
)
histories = sa.select(
(galaxy.model.Dataset.table.c.state.label("state"), galaxy.model.History.table.c.name.label("name")),
from_obj=from_obj,
whereclause=whereclause,
order_by=["name"],
histories = (
sa.select(
galaxy.model.Dataset.table.c.state.label("state"), galaxy.model.History.table.c.name.label("name")
)
.select_from(from_obj)
.where(whereclause)
.order_by("name")
)

# execute requests, replace None fields by "Unknown"
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/reports/controllers/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_stats(self, trans, **kwd):
et_dy_data = []

recent_jobs = sa.select(
((model.Job.id), (model.Job.create_time).label("create_time"), (model.Job.update_time).label("update_time"))
model.Job.id, model.Job.create_time.label("create_time"), model.Job.update_time.label("update_time")
)

for job in trans.sa_session.execute(recent_jobs):
Expand Down
Loading

0 comments on commit 00a600e

Please sign in to comment.