Commit 863d0f25 authored by Sid Stenersen's avatar Sid Stenersen
Browse files

Apply wmode settings

parent f789533e
Pipeline #33519 failed with stages
in 1 minute and 59 seconds
......@@ -121,12 +121,13 @@ export class DatasetDAO {
}
public static async paginatedListContent(
journalClient: IJournal | IJournalTransaction, dataset: DatasetModel, pagination: PaginationModel):
journalClient: IJournal | IJournalTransaction, dataset: DatasetModel, wmode: string, pagination: PaginationModel):
Promise<{ datasets: string[], nextPageCursor: string }> {
const output = { datasets: [], nextPageCursor: null };
if (!pagination.cursor) {
if (wmode !== Config.LS_MODE.DATASETS && !pagination.cursor) {
// Retrieve directories
let query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND)
......@@ -139,22 +140,25 @@ export class DatasetDAO {
(elem, index, self) => index === self.indexOf(elem) );
}
// Retrieve datasets
let query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND)
.filter('path', dataset.path);
if (pagination.cursor) {
query = query.start(pagination.cursor);
}
if (pagination.limit) {
query = query.limit(pagination.limit);
}
if (wmode !== Config.LS_MODE.DIRS) {
// Retrieve datasets
let query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND)
.filter('path', dataset.path);
if (pagination.cursor) {
query = query.start(pagination.cursor);
}
if (pagination.limit) {
query = query.limit(pagination.limit);
}
const [entitiesds, info] = await journalClient.runQuery(query);
if (entitiesds.length !== 0) {
output.datasets = output.datasets.concat(entitiesds.map((item) => item.name));
if (pagination) {
output.nextPageCursor = info.endCursor;
const [entitiesds, info] = await journalClient.runQuery(query);
if (entitiesds.length !== 0) {
output.datasets = output.datasets.concat(entitiesds.map((item) => item.name));
if (pagination) {
output.nextPageCursor = info.endCursor;
}
}
}
return output;
......@@ -195,7 +199,7 @@ export class DatasetDAO {
const results = { datasets: [], directories: [] };
// Retrieve the content datasets
if (wmode === Config.LS_MODE.ALL || wmode === Config.LS_MODE.DATASETS) {
if (wmode !== Config.LS_MODE.DIRS) {
const query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND)
.filter('path', dataset.path);
......@@ -206,7 +210,7 @@ export class DatasetDAO {
}
// Extract all the directories structure and get the subdirectories for the required directory
if (wmode === Config.LS_MODE.ALL || wmode === Config.LS_MODE.DIRS) {
if (wmode !== Config.LS_MODE.DATASETS) {
const query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND)
.select(['path']).groupBy('path').filter('path', '>', dataset.path).filter('path', '<', dataset.path + '\ufffd');
......
......@@ -172,7 +172,7 @@ export class UtilityHandler {
if (pagination) {
// Retrieve paginated content list
return await DatasetDAO.paginatedListContent(journalClient, dataset, pagination);
return await DatasetDAO.paginatedListContent(journalClient, dataset, wmode, pagination);
}
// Retrieve complete content list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment