mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-21 00:01:29 +02:00
feat(import): convert deduplicate fields field into list
This commit is contained in:
@@ -4,10 +4,8 @@ from pydantic import BaseModel, Field, model_validator, field_validator
|
||||
|
||||
class CompareDeduplicationRule(BaseModel):
|
||||
type: Literal["compare"]
|
||||
fields: Dict = Field(
|
||||
..., description="Match header and fields to compare for deduplication"
|
||||
)
|
||||
match_type: Literal["lax", "strict"]
|
||||
fields: list[str] = Field(..., description="Compare fields for deduplication")
|
||||
match_type: Literal["lax", "strict"] = "lax"
|
||||
|
||||
@field_validator("fields", mode="before")
|
||||
def coerce_fields_to_dict(cls, v):
|
||||
|
||||
@@ -285,7 +285,7 @@ class ImportService:
|
||||
query = Transaction.all_objects.all().values("id")
|
||||
|
||||
# Build query conditions for each field in the rule
|
||||
for field, header in rule.fields.items():
|
||||
for field in rule.fields:
|
||||
if field in transaction_data:
|
||||
if rule.match_type == "strict":
|
||||
query = query.filter(**{field: transaction_data[field]})
|
||||
|
||||
Reference in New Issue
Block a user