-
Notifications
You must be signed in to change notification settings - Fork 2
Not showing meta-analysis experiments in creating score set dropdown menu. #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d464740
66ff1d9
c740d6b
66140c3
eb8bc0d
4301d32
f36bfdb
b81f19d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| from fastapi import APIRouter, Depends, HTTPException | ||
| from fastapi.encoders import jsonable_encoder | ||
| from sqlalchemy.orm import Session | ||
| from sqlalchemy import or_ | ||
|
|
||
| from mavedb import deps | ||
| from mavedb.lib.authentication import UserData, get_current_user | ||
|
|
@@ -43,7 +44,7 @@ | |
| ) | ||
|
|
||
|
|
||
| # TODO: Rewrite this function. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets retain this function-- I think it still has utility for just listing all experiments.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I'll modify it so that we don't need to send the weird q to it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is ok to just leave it as is for this PR so we can get it released. We can just handle it at some point later-- it isn't hurting anything right now. |
||
| # None of any part calls this function. Feel free to modify it if we need it in the future. | ||
| @router.get( | ||
| "/experiments/", | ||
| status_code=200, | ||
|
|
@@ -53,30 +54,26 @@ | |
| def list_experiments( | ||
| *, | ||
| editable: Optional[bool] = None, | ||
| q: Optional[str] = None, | ||
| db: Session = Depends(deps.get_db), | ||
| user_data: Optional[UserData] = Depends(get_current_user), | ||
| ) -> list[Experiment]: | ||
| """ | ||
| List experiments. | ||
| """ | ||
| query = db.query(Experiment) | ||
| if q is not None: | ||
| save_to_logging_context({"query_string": q}) | ||
|
|
||
| if editable: | ||
| if user_data is None or user_data.user is None: | ||
| logger.debug(msg="User is anonymous; Cannot list their experiments.", extra=logging_context()) | ||
| return [] | ||
|
|
||
| if len(q) > 0: | ||
| logger.debug(msg="Listing experiments for the current user.", extra=logging_context()) | ||
| query = query.filter( | ||
| Experiment.created_by_id == user_data.user.id | ||
| ) # .filter(Experiment.published_date is None) | ||
| # else: | ||
| # query = query.filter(Experiment.created_by_id == user.id).filter(Experiment.published_date is None) | ||
| else: | ||
| logger.debug(msg="No query string was provided; Listing all experiments.", extra=logging_context()) | ||
| logger.debug(msg="Listing experiments for the current user.", extra=logging_context()) | ||
| query = query.filter( | ||
| or_( | ||
| Experiment.created_by_id == user_data.user.id, | ||
| Experiment.contributors.any(Contributor.orcid_id == user_data.user.username) | ||
| ) | ||
| ) | ||
|
|
||
| items = query.order_by(Experiment.urn).all() | ||
| return items | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.