mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Admin Panel / People showed the admin on every one of its 578 pages, and Admin Panel / Problems / Broken cards was one endless page under a pager that said "1 / 1". Same bug in two shapes: the pane subscribes to a publication that sends exactly one page, then reads the page back out of minimongo - which holds far more than the page. The logged-in user's own record is always there (accounts publishes it), and so is every card of every board the admin has opened. A plain find(query) cannot tell those apart from the page. So the server names the page. getPeoplePageIds returns the ids of the People page with the publication's own selector, sort and window; the Broken cards, Cards and Boards report publications send the ids of the page they just sent alongside it. Both panes render that list, in that order, and nothing else. Every paginated page in WeKan now loads ten rows at a time, from one constant - TABLE_PAGE_ROWS_PER_PAGE - including the pages that draw a pager of their own: the reports and event streams, the four People panes, Translation, the search pages and the archive. docs/Design/Page/Table.md records the rule and its two deliberate exceptions. And the counting behind those pagers is index-backed. Every count already asks the database for a count rather than fetching the rows, but several counted and paged on unindexed fields: People sorts users newest-first, so on an instance with 14000 users each page of ten sorted all 14000 first. Broken cards asks an $or over boardId/swimlaneId/listId/type, which uses no index at all unless every branch has one. The missing indexes are created at startup by the idempotent ensureIndex, so an upgrade adds them by itself. Thanks to xet7 !
99 lines
2.5 KiB
JavaScript
99 lines
2.5 KiB
JavaScript
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { Meteor } from 'meteor/meteor';
|
|
const { SimpleSchema } = require('/imports/simpleSchema');
|
|
|
|
const Rules = new Mongo.Collection('rules');
|
|
|
|
Rules.attachSchema(
|
|
new SimpleSchema({
|
|
title: {
|
|
type: String,
|
|
optional: false,
|
|
},
|
|
triggerId: {
|
|
type: String,
|
|
optional: false,
|
|
},
|
|
actionId: {
|
|
type: String,
|
|
optional: false,
|
|
},
|
|
boardId: {
|
|
type: String,
|
|
optional: false,
|
|
},
|
|
// Denormalised manual-button metadata (only present on button rules). The
|
|
// board view renders board/card buttons from the rule alone — see
|
|
// server/rulesButton.js (rules.createRule) for why the trigger document is
|
|
// not relied upon on the client.
|
|
buttonType: {
|
|
type: String,
|
|
optional: true,
|
|
allowedValues: ['card', 'board'],
|
|
},
|
|
buttonLabel: {
|
|
type: String,
|
|
optional: true,
|
|
},
|
|
createdAt: {
|
|
type: Date,
|
|
optional: true,
|
|
// eslint-disable-next-line consistent-return
|
|
autoValue() {
|
|
if (this.isInsert) {
|
|
return new Date();
|
|
} else if (this.isUpsert) {
|
|
return { $setOnInsert: new Date() };
|
|
} else {
|
|
this.unset();
|
|
}
|
|
},
|
|
},
|
|
modifiedAt: {
|
|
type: Date,
|
|
// eslint-disable-next-line consistent-return
|
|
autoValue() {
|
|
if (this.isInsert || this.isUpsert || this.isUpdate) {
|
|
return new Date();
|
|
} else {
|
|
this.unset();
|
|
}
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
|
|
Rules.helpers({
|
|
async rename(description) {
|
|
return await Rules.updateAsync(this._id, { $set: { description } });
|
|
},
|
|
getAction() {
|
|
return ReactiveCache.getAction(this.actionId);
|
|
},
|
|
getTrigger() {
|
|
return ReactiveCache.getTrigger(this.triggerId);
|
|
},
|
|
board() {
|
|
return ReactiveCache.getBoard(this.boardId);
|
|
},
|
|
trigger() {
|
|
return ReactiveCache.getTrigger(this.triggerId);
|
|
},
|
|
action() {
|
|
return ReactiveCache.getAction(this.actionId);
|
|
},
|
|
});
|
|
|
|
if (Meteor.isServer) {
|
|
// Admin Panel / Problems / Rules pages every rule sorted by board, and counts
|
|
// them with the same selector (server/publications/rules.js). Without an index
|
|
// that is a full-collection scan plus an in-memory sort for every page of ten.
|
|
const { ensureIndex } = require('/server/lib/mongoStartup');
|
|
Meteor.startup(async () => {
|
|
await ensureIndex(Rules, { boardId: 1 });
|
|
});
|
|
}
|
|
|
|
export default Rules;
|