From 603f8d5aa99b01c887629cee18d6368787c4c854 Mon Sep 17 00:00:00 2001 From: Marko Jovanovic Date: Thu, 16 Oct 2025 14:22:17 +0200 Subject: [PATCH] Generate UUID and log parsed file line in clean-mobile command --- composer.json | 1 + composer.lock | 291 +++++++++++++++------------ migrations/Version20251014162123.php | 32 +++ migrations/Version20251016121932.php | 34 ++++ src/Command/CleanMobileCommand.php | 6 + src/Entity/Contacts.php | 40 ++++ 6 files changed, 271 insertions(+), 133 deletions(-) create mode 100644 migrations/Version20251014162123.php create mode 100644 migrations/Version20251016121932.php diff --git a/composer.json b/composer.json index 5837abc..b4ad794 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "symfony/framework-bundle": "7.3.*", "symfony/http-client": "7.3.*", "symfony/runtime": "7.3.*", + "symfony/uid": "7.3.*", "symfony/yaml": "7.3.*" }, "config": { diff --git a/composer.lock b/composer.lock index a876427..b5dd677 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b9305001e2268ecfb0a0152c539f85b1", + "content-hash": "1af0b665fd5f794fe772761a11bc109e", "packages": [ { "name": "doctrine/collections", @@ -1130,138 +1130,6 @@ }, "time": "2025-01-24T11:45:48+00:00" }, - { - "name": "giggsey/libphonenumber-for-php", - "version": "9.0.16", - "source": { - "type": "git", - "url": "https://github.com/giggsey/libphonenumber-for-php.git", - "reference": "c513a04df3824e9f19082d935bb8f331741252d1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/c513a04df3824e9f19082d935bb8f331741252d1", - "reference": "c513a04df3824e9f19082d935bb8f331741252d1", - "shasum": "" - }, - "require": { - "giggsey/locale": "^2.7", - "php": "^8.1", - "symfony/polyfill-mbstring": "^1.31" - }, - "replace": { - "giggsey/libphonenumber-for-php-lite": "self.version" - }, - "require-dev": { - "ext-dom": "*", - "friendsofphp/php-cs-fixer": "^3.71", - "infection/infection": "^0.29|^0.31.0", - "nette/php-generator": "^4.1", - "php-coveralls/php-coveralls": "^2.7", - "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan": "^2.1.7", - "phpstan/phpstan-deprecation-rules": "^2.0.1", - "phpstan/phpstan-phpunit": "^2.0.4", - "phpstan/phpstan-strict-rules": "^2.0.3", - "phpunit/phpunit": "^10.5.45", - "symfony/console": "^6.4", - "symfony/filesystem": "^6.4", - "symfony/process": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.x-dev" - } - }, - "autoload": { - "psr-4": { - "libphonenumber\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Joshua Gigg", - "email": "giggsey@gmail.com", - "homepage": "https://giggsey.com/" - } - ], - "description": "A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.", - "homepage": "https://github.com/giggsey/libphonenumber-for-php", - "keywords": [ - "geocoding", - "geolocation", - "libphonenumber", - "mobile", - "phonenumber", - "validation" - ], - "support": { - "issues": "https://github.com/giggsey/libphonenumber-for-php/issues", - "source": "https://github.com/giggsey/libphonenumber-for-php" - }, - "time": "2025-10-10T10:55:56+00:00" - }, - { - "name": "giggsey/locale", - "version": "2.8.0", - "source": { - "type": "git", - "url": "https://github.com/giggsey/Locale.git", - "reference": "1cd8b3ad2d43e04f4c2c6a240495af44780f809b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/giggsey/Locale/zipball/1cd8b3ad2d43e04f4c2c6a240495af44780f809b", - "reference": "1cd8b3ad2d43e04f4c2c6a240495af44780f809b", - "shasum": "" - }, - "require": { - "php": "^8.1" - }, - "require-dev": { - "ext-json": "*", - "friendsofphp/php-cs-fixer": "^3.66", - "pear/pear-core-minimal": "^1.10", - "pear/pear_exception": "^1.0", - "pear/versioncontrol_git": "^0.5", - "phing/phing": "^2.17.4", - "php-coveralls/php-coveralls": "^2.7", - "phpunit/phpunit": "^10.5.45", - "symfony/console": "^6.4", - "symfony/filesystem": "6.4", - "symfony/finder": "^6.4", - "symfony/process": "^6.4", - "symfony/var-exporter": "^6.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Giggsey\\Locale\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Joshua Gigg", - "email": "giggsey@gmail.com", - "homepage": "https://giggsey.com/" - } - ], - "description": "Locale functions required by libphonenumber-for-php", - "support": { - "issues": "https://github.com/giggsey/Locale/issues", - "source": "https://github.com/giggsey/Locale/tree/2.8.0" - }, - "time": "2025-03-20T14:25:27+00:00" - }, { "name": "league/csv", "version": "9.26.0", @@ -3652,6 +3520,89 @@ ], "time": "2025-06-24T13:30:11+00:00" }, + { + "name": "symfony/polyfill-uuid", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-uuid.git", + "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/21533be36c24be3f4b1669c4725c7d1d2bab4ae2", + "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-uuid": "*" + }, + "suggest": { + "ext-uuid": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Uuid\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for uuid functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, { "name": "symfony/routing", "version": "v7.3.2", @@ -4052,6 +4003,80 @@ ], "time": "2025-08-25T06:35:40+00:00" }, + { + "name": "symfony/uid", + "version": "v7.3.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/uid.git", + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/uid/zipball/a69f69f3159b852651a6bf45a9fdd149520525bb", + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-uuid": "^1.15" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Uid\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to generate and represent UIDs", + "homepage": "https://symfony.com", + "keywords": [ + "UID", + "ulid", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/uid/tree/v7.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-27T19:55:54+00:00" + }, { "name": "symfony/var-dumper", "version": "v7.3.3", diff --git a/migrations/Version20251014162123.php b/migrations/Version20251014162123.php new file mode 100644 index 0000000..3d690a8 --- /dev/null +++ b/migrations/Version20251014162123.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE contacts ADD study_id VARCHAR(50) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE contacts DROP study_id'); + } +} diff --git a/migrations/Version20251016121932.php b/migrations/Version20251016121932.php new file mode 100644 index 0000000..f317a53 --- /dev/null +++ b/migrations/Version20251016121932.php @@ -0,0 +1,34 @@ +addSql('ALTER TABLE contacts ADD parsed_file_linenum INT DEFAULT NULL'); + $this->addSql('ALTER TABLE contacts ADD parsed_file_line VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE contacts DROP parsed_file_linenum'); + $this->addSql('ALTER TABLE contacts DROP parsed_file_line'); + } +} diff --git a/src/Command/CleanMobileCommand.php b/src/Command/CleanMobileCommand.php index 3697f89..346f570 100644 --- a/src/Command/CleanMobileCommand.php +++ b/src/Command/CleanMobileCommand.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Command; use App\Entity\Contacts; +use Symfony\Component\Uid\Uuid; use Doctrine\ORM\EntityManagerInterface; use League\Csv\Reader; use League\Csv\Writer; @@ -183,6 +184,8 @@ final class CleanMobileCommand extends Command } if ($row['HANDY_E164']) { + $uuid = Uuid::v4(); + // Create a Contact entity for DB insertion $contact = new Contacts(); $contact->setPhoneNumber($row['HANDY_E164']); @@ -191,6 +194,9 @@ final class CleanMobileCommand extends Command $contact->setContacted(false); $contact->setParsedFilename($inputPath); $contact->setParsedAt(new \DateTimeImmutable()); + $contact->setStudyId($uuid->toString()); + $contact->setParsedFileLinenum($rowCount + 1); + $contact->setParsedFileLine(implode(';', $row)); $validContacts[] = $contact; } diff --git a/src/Entity/Contacts.php b/src/Entity/Contacts.php index 68ede69..e7ef1db 100644 --- a/src/Entity/Contacts.php +++ b/src/Entity/Contacts.php @@ -31,9 +31,19 @@ class Contacts #[ORM\Column(length: 255, nullable: true)] private ?string $parsed_filename = null; + #[ORM\Column(nullable: true)] + private ?int $parsed_file_linenum = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $parsed_file_line = null; + #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $parsed_at = null; + #[ORM\Column(length: 50, nullable: true)] + private ?string $study_id = null; + + public function getId(): ?int { return $this->id; @@ -118,4 +128,34 @@ class Contacts { $this->parsed_at = $parsed_at; } + + public function getStudyId(): ?string + { + return $this->study_id; + } + + public function setStudyId(?string $study_id): void + { + $this->study_id = $study_id; + } + + public function getParsedFileLinenum(): ?int + { + return $this->parsed_file_linenum; + } + + public function setParsedFileLinenum(?int $parsed_file_linenum): void + { + $this->parsed_file_linenum = $parsed_file_linenum; + } + + public function getParsedFileLine(): ?string + { + return $this->parsed_file_line; + } + + public function setParsedFileLine(?string $parsed_file_line): void + { + $this->parsed_file_line = $parsed_file_line; + } }