Skip to content

Commit

Permalink
refactor: removed software-side sorting logic, fixes #904
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Dec 24, 2024
1 parent 4d1a810 commit 2bd69c6
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/renderer/components/WorkspaceTabQueryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const settingsStore = useSettingsStore();
const consoleStore = useConsoleStore();
const { getWorkspace } = useWorkspacesStore();
const { dataTabLimit: pageSize, defaultCopyType } = storeToRefs(settingsStore);
const { /* dataTabLimit: pageSize, */ defaultCopyType } = storeToRefs(settingsStore);
const { consoleHeight } = storeToRefs(consoleStore);
Expand Down Expand Up @@ -357,37 +357,37 @@ const isSortable = computed(() => {
return fields.value.every(field => field.name);
});
const isHardSort = computed(() => {
return props.mode === 'table' && localResults.value.length === pageSize.value;
});
// const isHardSort = computed(() => {
// return props.mode === 'table' && localResults.value.length === pageSize.value;
// });
const sortedResults = computed(() => {
if (currentSort.value[resultsetIndex.value] && !isHardSort.value) {
const sortObj = currentSort.value[resultsetIndex.value];
return [...localResults.value].sort((a: any, b: any) => {
const modifier = sortObj.dir === 'desc' ? -1 : 1;
let valA = a[sortObj.field];
let valB = b[sortObj.field];
// Handle null values
if (valA === null && valB !== null) return sortObj.dir === 'asc' ? -1 : 1;
if (valA !== null && valB === null) return sortObj.dir === 'asc' ? 1 : -1;
if (valA === null && valB === null) return 0;
valA = typeof valA === 'string' ? valA.toLowerCase() : valA;
valB = typeof valB === 'string' ? valB.toLowerCase() : valB;
if (typeof valA !== 'number' && !isNaN(valA)) valA = String(Number(valA));
if (typeof valB !== 'number' && !isNaN(valB)) valB = String(Number(valB));
if (valA < valB) return -1 * modifier;
if (valA > valB) return 1 * modifier;
return 0;
});
}
else
return localResults.value;
// if (currentSort.value[resultsetIndex.value] && !isHardSort.value) {
// const sortObj = currentSort.value[resultsetIndex.value];
// return [...localResults.value].sort((a: any, b: any) => {
// const modifier = sortObj.dir === 'desc' ? -1 : 1;
// let valA = a[sortObj.field];
// let valB = b[sortObj.field];
// // Handle null values
// if (valA === null && valB !== null) return sortObj.dir === 'asc' ? -1 : 1;
// if (valA !== null && valB === null) return sortObj.dir === 'asc' ? 1 : -1;
// if (valA === null && valB === null) return 0;
// valA = typeof valA === 'string' ? valA.toLowerCase() : valA;
// valB = typeof valB === 'string' ? valB.toLowerCase() : valB;
// if (typeof valA !== 'number' && !isNaN(valA)) valA = String(Number(valA));
// if (typeof valB !== 'number' && !isNaN(valB)) valB = String(Number(valB));
// if (valA < valB) return -1 * modifier;
// if (valA > valB) return 1 * modifier;
// return 0;
// });
// }
// else
return localResults.value;
});
const resultsWithRows = computed(() => props.results.filter(result => result.rows.length));
Expand Down Expand Up @@ -827,12 +827,12 @@ const sort = (field: TableField) => {
};
}
if (isHardSort.value) {
emit('hard-sort', {
field: currentSort.value[resultsetIndex.value].field,
dir: currentSort.value[resultsetIndex.value].dir
});
}
// if (isHardSort.value) {
emit('hard-sort', {
field: currentSort.value[resultsetIndex.value].field,
dir: currentSort.value[resultsetIndex.value].dir
});
// }
};
const resetSort = () => {
Expand Down

0 comments on commit 2bd69c6

Please sign in to comment.