Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
matrix:
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
mariadb-versions: ['10.6', '10.11']
mariadb-versions: ['10.6', '10.11', '11.8']

name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}

Expand All @@ -84,8 +84,8 @@ jobs:
ports:
- 4444:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
MARIADB_ROOT_PASSWORD: rootpassword
options: --health-cmd="mariadb-admin ping" --health-interval 5s --health-timeout 2s --health-retries 5

steps:
- name: Set app env
Expand Down
21 changes: 13 additions & 8 deletions lib/Db/FaceDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
* @method float getY()
* @method float getHeight()
* @method float getWidth()
* @method float[] getVector()
* @method setVector(array $vector)
* @method setX(float $x)
* @method setY(float $y)
* @method setHeight(float $height)
* @method setWidth(float $width)
* @method setClusterId(int|null $clusterId)
* @method int|null getClusterId()
* @method float getThreshold()
* @method setThreshold(float $threshold)
* @method setThreshold(float $threshold)
*/
class FaceDetection extends Entity {
protected $fileId;
Expand All @@ -39,17 +37,17 @@
protected $y;
protected $height;
protected $width;
protected $vector;
protected $faceVector;

Check failure on line 40 in lib/Db/FaceDetection.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

MissingPropertyType

lib/Db/FaceDetection.php:40:12: MissingPropertyType: Property OCA\Recognize\Db\FaceDetection::$faceVector does not have a declared type (see https://psalm.dev/045)
protected $clusterId;
protected $threshold;
/**
* @var string[]
*/
public static $columns = ['id', 'user_id', 'file_id', 'x', 'y', 'height', 'width', 'vector', 'cluster_id', 'threshold'];
public static $columns = ['id', 'user_id', 'file_id', 'x', 'y', 'height', 'width', 'face_vector', 'cluster_id', 'threshold'];
/**
* @var string[]
*/
public static $fields = ['id', 'userId', 'fileId', 'x', 'y', 'height', 'width', 'vector', 'clusterId', 'threshold'];
public static $fields = ['id', 'userId', 'fileId', 'x', 'y', 'height', 'width', 'faceVector', 'clusterId', 'threshold'];

public function __construct() {
// add types in constructor
Expand All @@ -60,19 +58,26 @@
$this->addType('y', 'float');
$this->addType('height', 'float');
$this->addType('width', 'float');
$this->addType('vector', 'json');
$this->addType('faceVector', 'json');
$this->addType('clusterId', 'integer');
$this->addType('threshold', 'float');
}

public function toArray(): array {
$array = [];
foreach (static::$fields as $field) {
if ($field === 'vector') {
if ($field === 'faceVector') {
continue;
}
$array[$field] = $this->{$field};
}
return $array;
}

public function getVector(): array {
return $this->getter('faceVector');

Check failure on line 78 in lib/Db/FaceDetection.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

MixedReturnStatement

lib/Db/FaceDetection.php:78:10: MixedReturnStatement: Could not infer a return type (see https://psalm.dev/138)
}
public function setVector(array $vector): void {
$this->setter('faceVector', [$vector]);
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version002002000Date20220614094721.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->addColumn('width', Types::FLOAT, [
'notnull' => false,
]);
$table->addColumn('vector', Types::TEXT, [
$table->addColumn('face_vector', Types::TEXT, [
'notnull' => true,
]);
$table->addColumn('cluster_id', 'bigint', [
Expand Down
68 changes: 68 additions & 0 deletions lib/Migration/Version010000001Date20250727094721.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* Copyright (c) 2020-2025 The Recognize contributors.
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
*/
declare(strict_types=1);
namespace OCA\Recognize\Migration;

use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

final class Version010000001Date20250727094721 extends SimpleMigrationStep {

public function __construct(
private IDBConnection $db,
) {
}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return ?ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if ($schema->hasTable('recognize_face_detections')) {
$table = $schema->getTable('recognize_face_detections');
if (!$table->hasColumn('face_vector')) {
$table->addColumn('face_vector', Types::TEXT, [
'notnull' => true,
]);
return $schema;
}
}
return null;
}

public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable('recognize_face_detections')) {
return;
}

$table = $schema->getTable('recognize_face_detections');
$copyData = $table->hasColumn('face_vector') && $table->hasColumn('vector');
if (!$copyData) {
return;
}

$query = $this->db->getQueryBuilder();
$query->update('recognize_face_detections')
->set('face_vector', 'vector');
$query->executeStatement();
}
}
39 changes: 39 additions & 0 deletions lib/Migration/Version010000001Date20250727094821.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* Copyright (c) 2020-2025 The Recognize contributors.
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
*/
declare(strict_types=1);
namespace OCA\Recognize\Migration;

use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

final class Version010000001Date20250727094821 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return ?ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if ($schema->hasTable('recognize_face_detections')) {
$table = $schema->getTable('recognize_face_detections');
if ($table->hasColumn('vector')) {
$table->dropColumn('vector');
return $schema;
}
}
return null;
}
}
Loading