mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Five more of the features other kanban apps call AI, done with plain code (docs/Features/General/Assistants/Assistants.md): - Board menu -> Summary: what each person did in the last day or week - done, moved, added, commented - and what they have overdue, from the activities and History; Copy as text gives Markdown with card links. - Board menu -> Since your last visit (N): what others changed since the visit before this one, by card. The visit is kept in profile.boardVisits, at most 500 boards. - At risk: a weighted score of overdue, due soon with little done, blocked, idle in a middle list and sent back; a triangle on the minicard and the reasons in the opened card. - Suggested members in the Members and Assignees popups, from who handles the same labels, list and swimlane. - Forecast done date: the 50th and 85th percentile of the board's cycle times, counting only the cards that took at least as long as this one has been open. The server sends the times once per board, numbers only. Summary and Since your last visit are features of Admin Panel / Settings / Visibility / Features; At risk, Suggested members and Forecast are rows of Board Settings / Card and of the Admin Panel's Card fields. Every server answer applies the board's read rules and the assigned-only role. Translated in every language. The guards of the earlier helpers are brought up to date as well: the date words of models/lib/titleDueDate.js are a reviewed RegExp site, server/methods/ruleSuggestions.js is a board-admin-only path, the Rules page's list branch carries the suggestions, and Tigre's new strings use its own word for a board. Thanks to xet7 !
38 lines
1.8 KiB
JavaScript
38 lines
1.8 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { check } from 'meteor/check';
|
|
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
|
|
import Cards from '/models/cards';
|
|
import { boardForCardHelper } from '/server/lib/assistGate';
|
|
|
|
// Forecast done date (docs/Features/Cards/Dates/Forecast.md). The board's
|
|
// cycle times, once per board: how long each card finished in the last 180
|
|
// days took, as numbers - no title, no id, nothing else of any card. The
|
|
// opened card and the minicards compute their own forecast from them
|
|
// (models/lib/cardForecast.js), so a board of 500 cards asks once, not 500
|
|
// times. An assigned-only member gets the times of their own cards only.
|
|
const { cycleTimes, WINDOW_DAYS } = require('/models/lib/cardForecast');
|
|
const { assignedOnlyCardScope, mergeCardScope } = require('/models/lib/boardCardScope');
|
|
|
|
const MAX_CARDS = 5000;
|
|
const FIELDS = { startAt: 1, createdAt: 1, endAt: 1, archived: 1, archivedAt: 1, dueComplete: 1, modifiedAt: 1, dateLastActivity: 1 };
|
|
|
|
Meteor.methods({
|
|
async 'boards.cycleTimes'(boardId) {
|
|
check(boardId, String);
|
|
const board = await boardForCardHelper(this.userId, boardId, 'forecast', 'allowsForecastOnCard')
|
|
|| await boardForCardHelper(this.userId, boardId, 'forecast', 'allowsForecastOnMinicard');
|
|
if (!board) return [];
|
|
const since = new Date(Date.now() - WINDOW_DAYS * 24 * 60 * 60 * 1000);
|
|
const finished = await Cards.find(
|
|
mergeCardScope(
|
|
{ boardId, $or: [{ endAt: { $gte: since } }, { archivedAt: { $gte: since } }, { dueComplete: true, modifiedAt: { $gte: since } }] },
|
|
assignedOnlyCardScope(board, this.userId),
|
|
),
|
|
{ fields: FIELDS, limit: MAX_CARDS, sort: { modifiedAt: -1 } },
|
|
).fetchAsync();
|
|
return cycleTimes(finished);
|
|
},
|
|
});
|
|
|
|
DDPRateLimiter.addRule({ type: 'method', name: 'boards.cycleTimes', connectionId: () => true }, 20, 10000);
|