feat: complete person identity matching system with fuzzy detection, revert, and manual link
Implements the full identity matching engine: email matching (HIGH confidence), fuzzy name matching with Levenshtein distance (MEDIUM confidence, upgradable to HIGH with DOB tiebreaker), manual link/unlink, revert confirmed matches, and automatic detection via PersonObserver. Includes 33 comprehensive tests, frontend integration with confirm/dismiss/unlink UI, and match indicators in the persons list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,15 @@ final class Person extends Model
|
||||
public function pendingIdentityMatch(): HasOne
|
||||
{
|
||||
return $this->hasOne(PersonIdentityMatch::class)
|
||||
->where('status', IdentityMatchStatus::PENDING);
|
||||
->where('status', IdentityMatchStatus::PENDING)
|
||||
->latest();
|
||||
}
|
||||
|
||||
public function confirmedIdentityMatch(): HasOne
|
||||
{
|
||||
return $this->hasOne(PersonIdentityMatch::class)
|
||||
->where('status', IdentityMatchStatus::CONFIRMED)
|
||||
->latest();
|
||||
}
|
||||
|
||||
public function scopeApproved(Builder $query): Builder
|
||||
|
||||
@@ -26,6 +26,13 @@ final class PersonIdentityMatch extends Model
|
||||
'matched_on',
|
||||
'confidence',
|
||||
'status',
|
||||
'match_details',
|
||||
'confirmed_by_user_id',
|
||||
'confirmed_at',
|
||||
'dismissed_by_user_id',
|
||||
'dismissed_at',
|
||||
'reverted_by_user_id',
|
||||
'reverted_at',
|
||||
'resolved_by_user_id',
|
||||
'resolved_at',
|
||||
];
|
||||
@@ -36,6 +43,10 @@ final class PersonIdentityMatch extends Model
|
||||
'matched_on' => IdentityMatchMethod::class,
|
||||
'confidence' => IdentityMatchConfidence::class,
|
||||
'status' => IdentityMatchStatus::class,
|
||||
'match_details' => 'array',
|
||||
'confirmed_at' => 'datetime',
|
||||
'dismissed_at' => 'datetime',
|
||||
'reverted_at' => 'datetime',
|
||||
'resolved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
@@ -55,6 +66,21 @@ final class PersonIdentityMatch extends Model
|
||||
return $this->belongsTo(User::class, 'resolved_by_user_id');
|
||||
}
|
||||
|
||||
public function confirmedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'confirmed_by_user_id');
|
||||
}
|
||||
|
||||
public function dismissedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'dismissed_by_user_id');
|
||||
}
|
||||
|
||||
public function revertedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reverted_by_user_id');
|
||||
}
|
||||
|
||||
public function scopePending(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status', IdentityMatchStatus::PENDING);
|
||||
@@ -69,4 +95,9 @@ final class PersonIdentityMatch extends Model
|
||||
{
|
||||
return $query->where('status', IdentityMatchStatus::DISMISSED);
|
||||
}
|
||||
|
||||
public function scopeForEvent(Builder $query, string $eventId): Builder
|
||||
{
|
||||
return $query->whereHas('person', fn (Builder $q) => $q->where('event_id', $eventId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ final class User extends Authenticatable
|
||||
protected $fillable = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'date_of_birth',
|
||||
'email',
|
||||
'password',
|
||||
'timezone',
|
||||
@@ -51,6 +52,7 @@ final class User extends Authenticatable
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date_of_birth' => 'date',
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user