hotsheet 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +21 -17
- package/dist/client/app.global.js +38 -38
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1051,17 +1051,21 @@ function ordinalValue(field, value) {
|
|
|
1051
1051
|
if (field === "status") return STATUS_RANK[value] ?? null;
|
|
1052
1052
|
return null;
|
|
1053
1053
|
}
|
|
1054
|
-
async function queryTickets(logic, conditions, sortBy, sortDir, requiredTag) {
|
|
1054
|
+
async function queryTickets(logic, conditions, sortBy, sortDir, requiredTag, includeArchived) {
|
|
1055
1055
|
const db = await getDb();
|
|
1056
|
-
const
|
|
1056
|
+
const systemWhere = [];
|
|
1057
|
+
const userWhere = [];
|
|
1057
1058
|
const values = [];
|
|
1058
1059
|
let paramIdx = 1;
|
|
1059
|
-
|
|
1060
|
+
systemWhere.push(`status != 'deleted'`);
|
|
1061
|
+
if (includeArchived !== true) {
|
|
1062
|
+
systemWhere.push(`status != 'archive'`);
|
|
1063
|
+
}
|
|
1060
1064
|
for (const cond of conditions) {
|
|
1061
1065
|
if (!QUERYABLE_FIELDS.has(cond.field)) continue;
|
|
1062
1066
|
const field = cond.field;
|
|
1063
1067
|
if (field === "up_next") {
|
|
1064
|
-
|
|
1068
|
+
userWhere.push(`up_next = $${paramIdx}`);
|
|
1065
1069
|
values.push(cond.value === "true");
|
|
1066
1070
|
paramIdx++;
|
|
1067
1071
|
continue;
|
|
@@ -1070,44 +1074,43 @@ async function queryTickets(logic, conditions, sortBy, sortDir, requiredTag) {
|
|
|
1070
1074
|
const ordVal = ordExpr !== null ? ordinalValue(field, cond.value) : null;
|
|
1071
1075
|
if (ordExpr !== null && ordVal !== null && ["lt", "lte", "gt", "gte"].includes(cond.operator)) {
|
|
1072
1076
|
const op = cond.operator === "lt" ? "<" : cond.operator === "lte" ? "<=" : cond.operator === "gt" ? ">" : ">=";
|
|
1073
|
-
|
|
1077
|
+
userWhere.push(`(${ordExpr}) ${op} $${paramIdx}`);
|
|
1074
1078
|
values.push(ordVal);
|
|
1075
1079
|
paramIdx++;
|
|
1076
1080
|
continue;
|
|
1077
1081
|
}
|
|
1078
1082
|
switch (cond.operator) {
|
|
1079
1083
|
case "equals":
|
|
1080
|
-
|
|
1084
|
+
userWhere.push(`${field} = $${paramIdx}`);
|
|
1081
1085
|
values.push(cond.value);
|
|
1082
1086
|
paramIdx++;
|
|
1083
1087
|
break;
|
|
1084
1088
|
case "not_equals":
|
|
1085
|
-
|
|
1089
|
+
userWhere.push(`${field} != $${paramIdx}`);
|
|
1086
1090
|
values.push(cond.value);
|
|
1087
1091
|
paramIdx++;
|
|
1088
1092
|
break;
|
|
1089
1093
|
case "contains":
|
|
1090
|
-
|
|
1094
|
+
userWhere.push(`${field} ILIKE $${paramIdx}`);
|
|
1091
1095
|
values.push(`%${cond.value}%`);
|
|
1092
1096
|
paramIdx++;
|
|
1093
1097
|
break;
|
|
1094
1098
|
case "not_contains":
|
|
1095
|
-
|
|
1099
|
+
userWhere.push(`${field} NOT ILIKE $${paramIdx}`);
|
|
1096
1100
|
values.push(`%${cond.value}%`);
|
|
1097
1101
|
paramIdx++;
|
|
1098
1102
|
break;
|
|
1099
1103
|
}
|
|
1100
1104
|
}
|
|
1101
1105
|
if (requiredTag !== void 0 && requiredTag !== "") {
|
|
1102
|
-
|
|
1106
|
+
systemWhere.push(`tags ILIKE $${paramIdx}`);
|
|
1103
1107
|
values.push(`%${requiredTag}%`);
|
|
1104
1108
|
paramIdx++;
|
|
1105
1109
|
}
|
|
1106
1110
|
const joiner = logic === "any" ? " OR " : " AND ";
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
whereClause += ` AND (${userConditions.join(joiner)})`;
|
|
1111
|
+
let whereClause = systemWhere.join(" AND ");
|
|
1112
|
+
if (userWhere.length > 0) {
|
|
1113
|
+
whereClause += ` AND (${userWhere.join(joiner)})`;
|
|
1111
1114
|
}
|
|
1112
1115
|
let orderBy;
|
|
1113
1116
|
switch (sortBy) {
|
|
@@ -17669,7 +17672,8 @@ var QueryTicketsSchema = external_exports.object({
|
|
|
17669
17672
|
})),
|
|
17670
17673
|
sort_by: external_exports.string().optional(),
|
|
17671
17674
|
sort_dir: SortDirSchema.optional(),
|
|
17672
|
-
required_tag: external_exports.string().optional()
|
|
17675
|
+
required_tag: external_exports.string().optional(),
|
|
17676
|
+
include_archived: external_exports.boolean().optional()
|
|
17673
17677
|
});
|
|
17674
17678
|
var UpdateSettingsSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
17675
17679
|
var BackupTierSchema = external_exports.enum(["5min", "hourly", "daily"]);
|
|
@@ -18466,8 +18470,8 @@ ticketRoutes.post("/tickets/query", async (c) => {
|
|
|
18466
18470
|
const raw = await c.req.json();
|
|
18467
18471
|
const parsed = parseBody(QueryTicketsSchema, raw);
|
|
18468
18472
|
if (!parsed.success) return c.json({ error: parsed.error }, 400);
|
|
18469
|
-
const { logic, conditions, sort_by, sort_dir, required_tag } = parsed.data;
|
|
18470
|
-
const tickets = await queryTickets(logic, conditions, sort_by, sort_dir, required_tag);
|
|
18473
|
+
const { logic, conditions, sort_by, sort_dir, required_tag, include_archived } = parsed.data;
|
|
18474
|
+
const tickets = await queryTickets(logic, conditions, sort_by, sort_dir, required_tag, include_archived);
|
|
18471
18475
|
return c.json(tickets);
|
|
18472
18476
|
});
|
|
18473
18477
|
|