mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 07:31:47 +01:00
Global search display total hits
* modify User model to store some session data for searches * Display total hits in search results
This commit is contained in:
parent
c11c3f9a88
commit
3214800741
5 changed files with 49 additions and 7 deletions
|
|
@ -1733,7 +1733,7 @@ Cards.mutations({
|
|||
Cards.globalSearch = queryParams => {
|
||||
const userId = Meteor.userId();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('userId:', userId);
|
||||
// console.log('userId:', userId);
|
||||
|
||||
const errors = {
|
||||
notFound: {
|
||||
|
|
@ -1756,7 +1756,7 @@ Cards.globalSearch = queryParams => {
|
|||
const queryBoards = [];
|
||||
queryParams.boards.forEach(query => {
|
||||
const boards = Boards.userSearch(userId, {
|
||||
title: query,
|
||||
title: new RegExp(query, 'i'),
|
||||
});
|
||||
if (boards.count()) {
|
||||
boards.forEach(board => {
|
||||
|
|
@ -1774,7 +1774,7 @@ Cards.globalSearch = queryParams => {
|
|||
const querySwimlanes = [];
|
||||
queryParams.swimlanes.forEach(query => {
|
||||
const swimlanes = Swimlanes.find({
|
||||
title: query,
|
||||
title: new RegExp(query, 'i'),
|
||||
});
|
||||
if (swimlanes.count()) {
|
||||
swimlanes.forEach(swim => {
|
||||
|
|
@ -1792,7 +1792,7 @@ Cards.globalSearch = queryParams => {
|
|||
const queryLists = [];
|
||||
queryParams.lists.forEach(query => {
|
||||
const lists = Lists.find({
|
||||
title: query,
|
||||
title: new RegExp(query, 'i'),
|
||||
});
|
||||
if (lists.count()) {
|
||||
lists.forEach(list => {
|
||||
|
|
@ -1885,7 +1885,7 @@ Cards.globalSearch = queryParams => {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('selector:', selector);
|
||||
// console.log('selector:', selector);
|
||||
const cards = Cards.find(selector, {
|
||||
fields: {
|
||||
_id: 1,
|
||||
|
|
@ -1906,7 +1906,16 @@ Cards.globalSearch = queryParams => {
|
|||
});
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('count:', cards.count());
|
||||
// console.log('count:', cards.count());
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Users.update(userId, {
|
||||
$set: {
|
||||
'sessionData.totalHits': cards.count(),
|
||||
'sessionData.lastHit': cards.count() > 50 ? 50 : cards.count(),
|
||||
},
|
||||
});
|
||||
}
|
||||
return { cards, errors };
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,33 @@ Users.attachSchema(
|
|||
optional: false,
|
||||
defaultValue: 'password',
|
||||
},
|
||||
sessionData: {
|
||||
/**
|
||||
* profile settings
|
||||
*/
|
||||
type: Object,
|
||||
optional: true,
|
||||
// eslint-disable-next-line consistent-return
|
||||
autoValue() {
|
||||
if (this.isInsert && !this.isSet) {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
},
|
||||
'sessionData.totalHits': {
|
||||
/**
|
||||
* Total hits from last search
|
||||
*/
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
'sessionData.lastHit': {
|
||||
/**
|
||||
* last hit that was returned
|
||||
*/
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue