🐛 Not all the data is shown in the shared with me section (#376)

* 🐛Not all the data is shown in the shared with me section
This commit is contained in:
Anton Shepilov
2024-02-26 18:07:59 +01:00
committed by GitHub
parent 62845798b9
commit 07fc285721
11 changed files with 124 additions and 75 deletions
@@ -283,11 +283,12 @@ export default class ESAndOpenSearch extends SearchAdapter implements SearchAdap
const esParamsWithScroll = {
...esParams,
size: parseInt(options.pagination.limitStr || "100"),
scroll: "1m",
scroll: "10m",
};
let esResponse: any;
let nextToken;
if (options.pagination.page_token) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@@ -297,18 +298,23 @@ export default class ESAndOpenSearch extends SearchAdapter implements SearchAdap
},
esOptions,
);
//the scroll token is also the same, and we do not get it from response
nextToken = options.pagination.page_token;
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
esResponse = await this.client.search(esParamsWithScroll, esOptions);
nextToken = esResponse.body?._scroll_id || "";
}
if (esResponse.statusCode !== 200) {
logger.error(`${this.name} - ${JSON.stringify(esResponse.body)}`);
}
const nextToken = esResponse.body?._scroll_id || "";
const hits = esResponse.body?.hits?.hits || [];
if (hits.length == 0) {
nextToken = false;
}
logger.debug(`${this.name} got response: ${JSON.stringify(esResponse)}`);
@@ -200,9 +200,10 @@ export default class MongoSearch extends SearchAdapter implements SearchAdapterI
const { query, sort, project } = buildSearchQuery<EntityType>(entityType, filters, options);
logger.info(`Search query: ${JSON.stringify(query)}`);
console.log(query);
let cursor = collection.find({ ...query }).sort(sort);
let cursor = collection.find(query).sort(sort);
if (project) {
cursor = cursor.project(project);
}
@@ -230,7 +231,7 @@ export default class MongoSearch extends SearchAdapter implements SearchAdapterI
const nextToken =
entities.length === parseInt(options.pagination.limitStr) &&
(parseInt(options.pagination.page_token) + 1).toString(10);
(parseInt(options.pagination.page_token || "0") + 1).toString(10);
const nextPage: Paginable = new Pagination(nextToken, options.pagination.limitStr || "100");
logger.info(`Found ${entities.length} results on entity ${searchPrefix}${index}`);
@@ -40,7 +40,7 @@ export default class SearchRepository<EntityType> {
options,
);
//2. Get database original objects from theses primary keys
//2. Get database original objects from these primary keys
for (const searchEntity of searchResults.getEntities().sort((a, b) => b.score - a.score)) {
const sourceEntity = await repository.findOne(searchEntity.primaryKey, {}, context);
if (sourceEntity) {