Update field handling in self-serve modules and add deleted_at to searchable fields in tasks and questions routes

This commit is contained in:
Jeppe Bundgaard
2026-01-08 14:19:20 +01:00
parent 137571d712
commit c7e5e037bc
4 changed files with 15 additions and 13 deletions
@@ -48,8 +48,8 @@ trait selfserve_lane_port_controller_t
// Log the port open event
$this->logLaneAction(selfserve_lane_log_action::OPEN_PORT, 200, ['port' => $port->name]);
// Open the relay
$this->shellyOpenPort($port);
return true;
return true; // TODO: Remove this in production
return $this->shellyOpenPort($port);
}
/**
@@ -63,7 +63,7 @@ class departmentSelfserveQuestionsRoute
}
$response->success(
$questions_o->setSearchableFields(['id', 'department', 'lane', 'product', 'question', 'description'])
$questions_o->setSearchableFields(['id', 'department', 'lane', 'product', 'question', 'description', 'deleted_at'])
->listObjectsWithPaginationIfSet(function ($question) {
$q = new department_selfserve_questions_o();
$q->select((int)$question['id']);
@@ -67,7 +67,7 @@ class departmentSelfserveTasksRoute
}
$response->success(
$tasks_o->setSearchableFields(['id', 'department', 'lane', 'product', 'question', 'task', 'description'])
$tasks_o->setSearchableFields(['id', 'department', 'lane', 'product', 'question', 'task', 'description', 'deleted_at'])
->listObjectsWithPaginationIfSet(function ($task) {
$t = new department_selfserve_tasks_o();
$t->select((int)$task['id']);
+11 -9
View File
@@ -443,14 +443,16 @@ trait db_object_t
// Fetch table fields to search
$fields = $this->searchableFields;
$fieldTypes = [];
$tmpFields = [];
$result = $mysqli->query("SHOW COLUMNS FROM {$this->table}");
while ($row = $result->fetch_assoc()) {
$tmpFields[] = $row['Field'];
$fieldTypes[$row['Field']] = $row['Type'];
}
$result->free();
if (empty($fields)) {
$fields = [];
$result = $mysqli->query("SHOW COLUMNS FROM {$this->table}");
while ($row = $result->fetch_assoc()) {
$fields[] = $row['Field'];
$fieldTypes[$row['Field']] = $row['Type'];
}
$result->free();
$fields = $tmpFields;
}
$whereClauses = [];
@@ -482,9 +484,9 @@ trait db_object_t
$temp = [];
foreach ( $value as $v ) {
// Determine the type of the field
$type = $fieldTypes[$field];
$type = $fieldTypes[$field] ?? '';
// If the field is an integer, cast the value to an integer
if (str_contains($type, 'int')) {
if (!empty($type) && str_contains($type, 'int')) {
$temp[] = "`$field` = $v";
} else {
$temp[] = "`$field` = ?";