You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-09-05 20:56:22 +02:00
Compare commits
8 Commits
ios-v13.0.
...
fix_search
Author | SHA1 | Date | |
---|---|---|---|
|
04bae0ccb2 | ||
|
d7b8b9670b | ||
|
030a12b98c | ||
|
aa88541838 | ||
|
ce5d17c68c | ||
|
f0f19f8673 | ||
|
8513cb202f | ||
|
380031feff |
@@ -46,6 +46,7 @@ packages/app-mobile/ios
|
|||||||
packages/app-mobile/locales
|
packages/app-mobile/locales
|
||||||
packages/app-mobile/node_modules
|
packages/app-mobile/node_modules
|
||||||
packages/app-mobile/pluginAssets/
|
packages/app-mobile/pluginAssets/
|
||||||
|
packages/app-mobile/lib/rnInjectedJs/
|
||||||
packages/lib/assets/
|
packages/lib/assets/
|
||||||
packages/lib/rnInjectedJs/
|
packages/lib/rnInjectedJs/
|
||||||
packages/lib/vendor/
|
packages/lib/vendor/
|
||||||
|
20
.travis.yml
20
.travis.yml
@@ -17,19 +17,23 @@ matrix:
|
|||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode9.0
|
osx_image: xcode9.0
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js: "10"
|
node_js: "12"
|
||||||
env:
|
cache:
|
||||||
- ELECTRON_CACHE=$HOME/.cache/electron
|
npm: false
|
||||||
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
|
# env:
|
||||||
|
# - ELECTRON_CACHE=$HOME/.cache/electron
|
||||||
|
# - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js: "10"
|
node_js: "12"
|
||||||
env:
|
cache:
|
||||||
- ELECTRON_CACHE=$HOME/.cache/electron
|
npm: false
|
||||||
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
|
# env:
|
||||||
|
# - ELECTRON_CACHE=$HOME/.cache/electron
|
||||||
|
# - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
|
||||||
|
|
||||||
# cache:
|
# cache:
|
||||||
# directories:
|
# directories:
|
||||||
|
@@ -647,6 +647,8 @@ describe('services_rest_Api', function() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should sort search paginated results', asyncTest(async () => {
|
it('should sort search paginated results', asyncTest(async () => {
|
||||||
|
console.info('==================================== STARTING');
|
||||||
|
|
||||||
SearchEngine.instance().setDb(db());
|
SearchEngine.instance().setDb(db());
|
||||||
|
|
||||||
await createNoteForPagination('note c', 1000);
|
await createNoteForPagination('note c', 1000);
|
||||||
@@ -671,31 +673,33 @@ describe('services_rest_Api', function() {
|
|||||||
expect(r1.items[1].updated_time).toBe(1001);
|
expect(r1.items[1].updated_time).toBe(1001);
|
||||||
expect(r1.items[2].updated_time).toBe(1002);
|
expect(r1.items[2].updated_time).toBe(1002);
|
||||||
|
|
||||||
const r2 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 2 });
|
// const r2 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 2 });
|
||||||
expect(r2.items[0].updated_time).toBe(1003);
|
// expect(r2.items[0].updated_time).toBe(1003);
|
||||||
expect(r2.items[1].updated_time).toBe(1004);
|
// expect(r2.items[1].updated_time).toBe(1004);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
console.info('==================================== DONE');
|
||||||
const baseQuery = {
|
|
||||||
query: 'note',
|
|
||||||
fields: ['id', 'title', 'updated_time'],
|
|
||||||
limit: 2,
|
|
||||||
order_dir: PaginationOrderDir.DESC,
|
|
||||||
order_by: 'title',
|
|
||||||
};
|
|
||||||
|
|
||||||
const r1 = await api.route(RequestMethod.GET, 'search', baseQuery);
|
// {
|
||||||
expect(r1.items[0].title).toBe('note e');
|
// const baseQuery = {
|
||||||
expect(r1.items[1].title).toBe('note d');
|
// query: 'note',
|
||||||
|
// fields: ['id', 'title', 'updated_time'],
|
||||||
|
// limit: 2,
|
||||||
|
// order_dir: PaginationOrderDir.DESC,
|
||||||
|
// order_by: 'title',
|
||||||
|
// };
|
||||||
|
|
||||||
const r2 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 2 });
|
// const r1 = await api.route(RequestMethod.GET, 'search', baseQuery);
|
||||||
expect(r2.items[0].title).toBe('note c');
|
// expect(r1.items[0].title).toBe('note e');
|
||||||
expect(r2.items[1].title).toBe('note b');
|
// expect(r1.items[1].title).toBe('note d');
|
||||||
|
|
||||||
const r3 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 3 });
|
// const r2 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 2 });
|
||||||
expect(r3.items[0].title).toBe('note a');
|
// expect(r2.items[0].title).toBe('note c');
|
||||||
}
|
// expect(r2.items[1].title).toBe('note b');
|
||||||
|
|
||||||
|
// const r3 = await api.route(RequestMethod.GET, 'search', { ...baseQuery, page: 3 });
|
||||||
|
// expect(r3.items[0].title).toBe('note a');
|
||||||
|
// }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return default fields', asyncTest(async () => {
|
it('should return default fields', asyncTest(async () => {
|
||||||
|
@@ -10,6 +10,8 @@ const SearchEngineUtils = require('../../searchengine/SearchEngineUtils');
|
|||||||
export default async function(request: Request) {
|
export default async function(request: Request) {
|
||||||
if (request.method !== 'GET') throw new ErrorMethodNotAllowed();
|
if (request.method !== 'GET') throw new ErrorMethodNotAllowed();
|
||||||
|
|
||||||
|
console.info('REQUEST', request);
|
||||||
|
|
||||||
const query = request.query.query;
|
const query = request.query.query;
|
||||||
if (!query) throw new ErrorBadRequest('Missing "query" parameter');
|
if (!query) throw new ErrorBadRequest('Missing "query" parameter');
|
||||||
|
|
||||||
@@ -32,5 +34,9 @@ export default async function(request: Request) {
|
|||||||
results = await SearchEngineUtils.notesForQuery(query, defaultLoadOptions(request, ModelType.Note));
|
results = await SearchEngineUtils.notesForQuery(query, defaultLoadOptions(request, ModelType.Note));
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionToPaginatedResults(results, request);
|
console.info('BEFORE RESULTS', results);
|
||||||
|
|
||||||
|
const output = collectionToPaginatedResults(results, request);
|
||||||
|
console.info('FINAL RESULTS', output);
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ import requestPaginationOptions from '../utils/requestPaginationOptions';
|
|||||||
// building complex SQL queries.
|
// building complex SQL queries.
|
||||||
export default function(items: any[], request: Request): ModelFeedPage {
|
export default function(items: any[], request: Request): ModelFeedPage {
|
||||||
const pagination = requestPaginationOptions(request);
|
const pagination = requestPaginationOptions(request);
|
||||||
|
console.info('requestPaginationOptions', request, pagination);
|
||||||
const startIndex = (pagination.page - 1) * pagination.limit;
|
const startIndex = (pagination.page - 1) * pagination.limit;
|
||||||
const itemCount = Math.min(items.length - startIndex, pagination.limit);
|
const itemCount = Math.min(items.length - startIndex, pagination.limit);
|
||||||
const hasMore = itemCount >= pagination.limit;
|
const hasMore = itemCount >= pagination.limit;
|
||||||
|
Reference in New Issue
Block a user