mirror of
https://github.com/plankanban/planka.git
synced 2025-12-06 01:10:11 +03:00
fix: Rename getCards inputs for consistency
This commit is contained in:
@@ -40,8 +40,8 @@ export function* fetchCards(listId) {
|
||||
try {
|
||||
response.body = yield call(request, api.getCards, listId, {
|
||||
search: (search && search.trim()) || undefined,
|
||||
filterUserIds: filterUserIds.length > 0 ? filterUserIds.join(',') : undefined,
|
||||
filterLabelIds: filterLabelIds.length > 0 ? filterLabelIds.join(',') : undefined,
|
||||
userIds: filterUserIds.length > 0 ? filterUserIds.join(',') : undefined,
|
||||
labelIds: filterLabelIds.length > 0 ? filterLabelIds.join(',') : undefined,
|
||||
before: lastCard || undefined,
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
* type: string
|
||||
* maxLength: 128
|
||||
* example: bug fix
|
||||
* - name: filterUserIds
|
||||
* - name: userIds
|
||||
* in: query
|
||||
* required: false
|
||||
* description: Comma-separated user IDs to filter by members
|
||||
* description: Comma-separated user IDs to filter by members or task assignees
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 1357158568008091265,1357158568008091266
|
||||
* - name: filterLabelIds
|
||||
* - name: labelIds
|
||||
* in: query
|
||||
* required: false
|
||||
* description: Comma-separated label IDs to filter by labels
|
||||
@@ -179,8 +179,8 @@ module.exports = {
|
||||
isNotEmptyString: true,
|
||||
maxLength: 128,
|
||||
},
|
||||
filterUserIds: idsInput,
|
||||
filterLabelIds: idsInput,
|
||||
userIds: idsInput,
|
||||
labelIds: idsInput,
|
||||
},
|
||||
|
||||
exits: {
|
||||
@@ -215,31 +215,31 @@ module.exports = {
|
||||
}
|
||||
|
||||
let filterUserIds;
|
||||
if (inputs.filterUserIds) {
|
||||
if (inputs.userIds) {
|
||||
const boardMemberships = await BoardMembership.qm.getByBoardId(list.boardId);
|
||||
|
||||
const availableUserIdsSet = new Set(
|
||||
sails.helpers.utils.mapRecords(boardMemberships, 'userId'),
|
||||
);
|
||||
|
||||
filterUserIds = _.uniq(inputs.filterUserIds.split(','));
|
||||
filterUserIds = _.uniq(inputs.userIds.split(','));
|
||||
filterUserIds = filterUserIds.filter((userId) => availableUserIdsSet.has(userId));
|
||||
}
|
||||
|
||||
let filterLabelIds;
|
||||
if (inputs.filterLabelIds) {
|
||||
if (inputs.labelIds) {
|
||||
const labels = await Label.qm.getByBoardId(list.boardId);
|
||||
const availableLabelIdsSet = new Set(sails.helpers.utils.mapRecords(labels));
|
||||
|
||||
filterLabelIds = _.uniq(inputs.filterLabelIds.split(','));
|
||||
filterLabelIds = _.uniq(inputs.labelIds.split(','));
|
||||
filterLabelIds = filterLabelIds.filter((labelId) => availableLabelIdsSet.has(labelId));
|
||||
}
|
||||
|
||||
const cards = await Card.qm.getByEndlessListId(list.id, {
|
||||
filterUserIds,
|
||||
filterLabelIds,
|
||||
before: inputs.before,
|
||||
search: inputs.search,
|
||||
userIds: filterUserIds,
|
||||
labelIds: filterLabelIds,
|
||||
});
|
||||
|
||||
const cardIds = sails.helpers.utils.mapRecords(cards);
|
||||
|
||||
@@ -12,28 +12,25 @@ const defaultFind = (criteria, { sort = 'id', limit } = {}) =>
|
||||
|
||||
/* Query methods */
|
||||
|
||||
const getIdsByEndlessListId = async (
|
||||
listId,
|
||||
{ before, search, filterUserIds, filterLabelIds } = {},
|
||||
) => {
|
||||
if (filterUserIds && filterUserIds.length === 0) {
|
||||
const getIdsByEndlessListId = async (listId, { before, search, userIds, labelIds } = {}) => {
|
||||
if (userIds && userIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (filterLabelIds && filterLabelIds.length === 0) {
|
||||
if (labelIds && labelIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const queryValues = [];
|
||||
let query = 'SELECT DISTINCT card.id FROM card';
|
||||
|
||||
if (filterUserIds) {
|
||||
if (userIds) {
|
||||
query += ' LEFT JOIN card_membership ON card.id = card_membership.card_id';
|
||||
query += ' LEFT JOIN task_list ON card.id = task_list.card_id';
|
||||
query += ' LEFT JOIN task ON task_list.id = task.task_list_id';
|
||||
}
|
||||
|
||||
if (filterLabelIds) {
|
||||
if (labelIds) {
|
||||
query += ' LEFT JOIN card_label ON card.id = card_label.card_id';
|
||||
}
|
||||
|
||||
@@ -66,18 +63,18 @@ const getIdsByEndlessListId = async (
|
||||
}
|
||||
}
|
||||
|
||||
if (filterUserIds) {
|
||||
const inValues = filterUserIds.map((filterUserId) => {
|
||||
queryValues.push(filterUserId);
|
||||
if (userIds) {
|
||||
const inValues = userIds.map((userId) => {
|
||||
queryValues.push(userId);
|
||||
return `$${queryValues.length}`;
|
||||
});
|
||||
|
||||
query += ` AND (card_membership.user_id IN (${inValues.join(', ')}) OR task.assignee_user_id IN (${inValues.join(', ')}))`;
|
||||
}
|
||||
|
||||
if (filterLabelIds) {
|
||||
const inValues = filterLabelIds.map((filterLabelId) => {
|
||||
queryValues.push(filterLabelId);
|
||||
if (labelIds) {
|
||||
const inValues = labelIds.map((labelId) => {
|
||||
queryValues.push(labelId);
|
||||
return `$${queryValues.length}`;
|
||||
});
|
||||
|
||||
@@ -126,19 +123,19 @@ const getByListId = async (listId, { exceptIdOrIds, sort = ['position', 'id'] }
|
||||
return defaultFind(criteria, { sort });
|
||||
};
|
||||
|
||||
const getByEndlessListId = async (listId, { before, search, filterUserIds, filterLabelIds }) => {
|
||||
const getByEndlessListId = async (listId, { before, search, userIds, labelIds }) => {
|
||||
const criteria = {};
|
||||
|
||||
const options = {
|
||||
sort: ['listChangedAt DESC', 'id DESC'],
|
||||
};
|
||||
|
||||
if (search || filterUserIds || filterLabelIds) {
|
||||
if (search || userIds || labelIds) {
|
||||
criteria.id = await getIdsByEndlessListId(listId, {
|
||||
before,
|
||||
search,
|
||||
filterUserIds,
|
||||
filterLabelIds,
|
||||
userIds,
|
||||
labelIds,
|
||||
});
|
||||
} else {
|
||||
criteria.and = [{ listId }];
|
||||
|
||||
Reference in New Issue
Block a user