Verified Commit c66e41f9 authored by Jakob Moser's avatar Jakob Moser
Browse files

Implement get person by full name

parent 18fcc8aa
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Literal, Self

from babel.numbers import format_currency
from sqlalchemy import select
from sqlalchemy.orm import Mapped, mapped_column, relationship

from poolpay.model.Base import Base
@@ -131,4 +132,14 @@ class Person(Base):

        If no persons can be found or there are too many plausible matches, None is returned.
        """
        raise NotImplementedError()
        # TODO Improve heuristics
        persons = (
            db.session.execute(select(cls).where(cls.name == full_name.split(" ")[0]))
            .scalars()
            .all()
        )

        if len(persons) != 1:
            return None

        return persons[0]