mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix duration filter
This commit is contained in:
@@ -49,6 +49,8 @@ export function addFilterAndApply(
|
||||
addStatusCodeFilter(value, colId, columns);
|
||||
} else if (colId === '$createdAt' || colId === '$updatedAt' || colId === 'buildDuration') {
|
||||
addDateFilter(value, colId, columns);
|
||||
} else if (colId === 'duration') {
|
||||
addDurationFilter(value, colId, columns);
|
||||
} else {
|
||||
addFilter(columns, colId, operator, value, arrayValues);
|
||||
}
|
||||
@@ -75,3 +77,7 @@ export function addDateFilter(value: string, colId: string, columns: Column[]) {
|
||||
export function addSizeFilter(value: string, colId: string, columns: Column[]) {
|
||||
addFilter(columns, colId, ValidOperators.GreaterThanOrEqual, value);
|
||||
}
|
||||
|
||||
export function addDurationFilter(value: string, colId: string, columns: Column[]) {
|
||||
addFilter(columns, colId, ValidOperators.GreaterThan, value);
|
||||
}
|
||||
|
||||
@@ -61,20 +61,12 @@ export function setTimeFilter(filter: FilterData, columns: Column[]) {
|
||||
const col = columns.find((c) => c.id === filter.id);
|
||||
const timeTag = get(tags).find((tag) => tag.tag.includes(`**${filter.title}**`));
|
||||
if (timeTag) {
|
||||
const now = new Date();
|
||||
|
||||
const diff = now.getTime() - new Date(timeTag.value as string).getTime();
|
||||
const ranges = col.elements as { value: string; label: string }[];
|
||||
const dateRange = ranges.reduce((prev, curr) => {
|
||||
if (parseInt(curr.value) < diff && curr.value > prev.value) {
|
||||
return curr;
|
||||
}
|
||||
return prev;
|
||||
});
|
||||
if (dateRange) {
|
||||
const timeRange = ranges.find((range) => range.value === timeTag.value);
|
||||
if (timeRange) {
|
||||
const newTag = {
|
||||
tag: `**${filter.title}** is **${dateRange.label}**`,
|
||||
value: timeTag.value
|
||||
tag: `**${filter.title}** is **${timeRange.label}**`,
|
||||
value: timeRange.value
|
||||
};
|
||||
|
||||
cleanOldTags(filter?.title);
|
||||
|
||||
Reference in New Issue
Block a user