web: fix notes tests

This commit is contained in:
Abdullah Atta
2023-11-24 15:04:10 +05:00
parent 73def8a682
commit 189a9da5b5
33 changed files with 314 additions and 222 deletions

View File

@@ -36,6 +36,7 @@ import {
import {
AnyColumnWithTable,
ExpressionOrFactory,
SelectExpression,
SelectQueryBuilder,
SqlBool,
sql
@@ -353,10 +354,29 @@ export class FilteredSelector<T extends Item> {
async grouped(options: GroupOptions) {
console.time("getting items");
const fields: Array<
SelectExpression<DatabaseSchema, keyof DatabaseSchema>
> = ["id", "type", options.sortBy];
if (this.type === "notes") fields.push("notes.pinned", "notes.conflicted");
else if (this.type === "notebooks") fields.push("notebooks.pinned");
else if (this.type === "attachments" && options.groupBy === "abc")
fields.push("attachments.filename");
else if (this.type === "reminders") {
fields.push(
"reminders.mode",
"reminders.date",
"reminders.recurringMode",
"reminders.selectedDays",
"reminders.disabled",
"reminders.snoozeUntil"
);
}
const items = await this.filter
.$if(!!this._limit, (eb) => eb.limit(this._limit))
.$call(this.buildSortExpression(options))
.select(["id", options.sortBy, "type"])
.select(fields)
.execute();
console.timeEnd("getting items");
console.log(items.length);

View File

@@ -60,7 +60,7 @@ function getKeySelector(
const date = new Date();
if (item.type === "reminder")
return "Active"; // isReminderActive(item) ? "Active" : "Inactive";
return isReminderActive(item) ? "Active" : "Inactive";
else if (options.sortBy === "title")
return getFirstCharacter(getTitle(item));
else {