céges meghívó kezelése,
This commit is contained in:
@@ -80,9 +80,21 @@ class ExpertiseTag(Base):
|
||||
"""
|
||||
Szakmai címkék mesterlistája (MB 2.0).
|
||||
Ez a tábla vezérli a robotok keresését és a Gamification pontozást is.
|
||||
|
||||
4-Level Category Hierarchy (2026-06-17):
|
||||
=========================================
|
||||
Level 0: Járműtípus (Vehicle Type) — e.g. "Személyautó", "Motorkerékpár"
|
||||
Level 1: Iparág/Főcsoport (Industry) — e.g. "Karbantartás és javítás", "Üzemanyagtöltő"
|
||||
Level 2: Szakma (Profession) — e.g. "Autószerelő", "Gumiszerviz"
|
||||
Level 3: Specifikus feladat/címke (Specific Tag) — e.g. "Vezérműszíj csere", "Klíma töltés"
|
||||
|
||||
Adjacency List (parent_id) + Materialized Path (path) for efficient tree queries.
|
||||
"""
|
||||
__tablename__ = "expertise_tags"
|
||||
__table_args__ = {"schema": "marketplace"}
|
||||
__table_args__ = (
|
||||
Index('idx_expertise_path', 'path'),
|
||||
{"schema": "marketplace"}
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
key: Mapped[str] = mapped_column(String(50), unique=True, index=True)
|
||||
@@ -90,6 +102,13 @@ class ExpertiseTag(Base):
|
||||
name_en: Mapped[Optional[str]] = mapped_column(String(100))
|
||||
category: Mapped[Optional[str]] = mapped_column(String(30), index=True)
|
||||
|
||||
# --- 🏗️ 4-LEVEL HIERARCHY (2026-06-17) ---
|
||||
parent_id: Mapped[Optional[int]] = mapped_column(
|
||||
Integer, ForeignKey("marketplace.expertise_tags.id"), nullable=True, index=True
|
||||
)
|
||||
level: Mapped[int] = mapped_column(Integer, default=0, server_default=text("0"), nullable=False)
|
||||
path: Mapped[Optional[str]] = mapped_column(String(255), nullable=True, index=True)
|
||||
|
||||
# --- 🎮 GAMIFICATION ÉS DISCOVERY ---
|
||||
is_official: Mapped[bool] = mapped_column(Boolean, default=True, server_default=text("true"))
|
||||
suggested_by_id: Mapped[Optional[int]] = mapped_column(BigInteger, ForeignKey("identity.persons.id"))
|
||||
@@ -102,6 +121,20 @@ class ExpertiseTag(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Self-referential relationship for tree traversal
|
||||
# NOTE: cascade="all, delete-orphan" is intentionally NOT set here because
|
||||
# this is a self-referential tree. Deleting a parent should NOT cascade-delete
|
||||
# children (they may be re-parented). The "many" side of a self-referential
|
||||
# relationship cannot have delete-orphan without single_parent=True.
|
||||
children: Mapped[List["ExpertiseTag"]] = relationship(
|
||||
"ExpertiseTag", back_populates="parent",
|
||||
remote_side=[id],
|
||||
)
|
||||
parent: Mapped[Optional["ExpertiseTag"]] = relationship(
|
||||
"ExpertiseTag", back_populates="children",
|
||||
remote_side=[parent_id],
|
||||
)
|
||||
|
||||
services: Mapped[List["ServiceExpertise"]] = relationship("ServiceExpertise", back_populates="tag")
|
||||
suggested_by: Mapped[Optional["Person"]] = relationship("Person")
|
||||
|
||||
@@ -173,4 +206,4 @@ class Cost(Base):
|
||||
occurrence_date: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, index=True)
|
||||
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|
||||
|
||||
Reference in New Issue
Block a user