-
Couldn't load subscription status.
- Fork 79
Fix metadata file retrieval #1653
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 5 commits
adee2bf
ae0bb1f
ac7ce82
b41da62
413dc4e
81580dd
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 |
|---|---|---|
|
|
@@ -645,7 +645,7 @@ def str_to_id(x): | |
| chain.from_iterable(qdb.sql_connection.TRN.execute()[idx:]))) | ||
|
|
||
|
|
||
| def retrieve_filepaths(obj_fp_table, obj_id_column, obj_id): | ||
| def retrieve_filepaths(obj_fp_table, obj_id_column, obj_id, sort=None): | ||
| """Retrieves the filepaths for the given object id | ||
|
|
||
| Parameters | ||
|
|
@@ -656,6 +656,9 @@ def retrieve_filepaths(obj_fp_table, obj_id_column, obj_id): | |
| The name of the column that represents the object id | ||
| obj_id : int | ||
| The object id | ||
| sort : {'ascendent', 'descendent'}, optional | ||
|
||
| The direction in which the results are sorted, using the filepath id | ||
| as sorting key. Default: None, no sorting is applyed | ||
|
||
|
|
||
| Returns | ||
| ------- | ||
|
|
@@ -670,14 +673,25 @@ def path_builder(db_dir, filepath, mountpoint, subdirectory, obj_id): | |
| else: | ||
| return join(db_dir, mountpoint, filepath) | ||
|
|
||
| sql_sort = "" | ||
| if sort == 'ascendent': | ||
| sql_sort = " ORDER BY filepath_id" | ||
| elif sort == 'descendent': | ||
| sql_sort = " ORDER BY filepath_id DESC" | ||
| elif sort is not None: | ||
| raise qdb.exceptions.QiitaDBError( | ||
| "Unknown sorting direction: %s. Please choose from 'ascendent' or " | ||
| "'descendent'" % sort) | ||
|
|
||
| with qdb.sql_connection.TRN: | ||
| sql = """SELECT filepath_id, filepath, filepath_type, mountpoint, | ||
| subdirectory | ||
| FROM qiita.filepath | ||
| JOIN qiita.filepath_type USING (filepath_type_id) | ||
| JOIN qiita.data_directory USING (data_directory_id) | ||
| JOIN qiita.{0} USING (filepath_id) | ||
| WHERE {1} = %s""".format(obj_fp_table, obj_id_column) | ||
| WHERE {1} = %s{2}""".format(obj_fp_table, obj_id_column, | ||
| sql_sort) | ||
| qdb.sql_connection.TRN.add(sql, [obj_id]) | ||
| results = qdb.sql_connection.TRN.execute_fetchindex() | ||
| db_dir = get_db_files_base_dir() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no
'qiime_map', this returnsNone. Does this warrant a test case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That case should never happen (i.e. all prep template objects should have the qiime_map).
However, in case that it doesn't exist, I think returning None is the correct approach.