forked from zovos/vk_hackathon
Fix date_range filter: convert ISO string to Unix timestamp for models.Range
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9db7d3544c
commit
e95ca82a4a
1 changed files with 10 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from qdrant_client import AsyncQdrantClient, models
|
||||
|
|
@ -14,6 +15,13 @@ from config import (
|
|||
from schemas import Question, SparseVector
|
||||
|
||||
|
||||
def _iso_to_unix(s: str) -> float:
|
||||
try:
|
||||
return datetime.fromisoformat(s.replace("Z", "+00:00")).timestamp()
|
||||
except (ValueError, AttributeError):
|
||||
return 0.0
|
||||
|
||||
|
||||
def _build_filter(question: Question) -> models.Filter | None:
|
||||
must_conditions: list[models.Condition] = []
|
||||
|
||||
|
|
@ -22,8 +30,8 @@ def _build_filter(question: Question) -> models.Filter | None:
|
|||
models.FieldCondition(
|
||||
key="metadata.start",
|
||||
range=models.Range(
|
||||
gte=question.date_range.from_,
|
||||
lte=question.date_range.to,
|
||||
gte=_iso_to_unix(question.date_range.from_),
|
||||
lte=_iso_to_unix(question.date_range.to),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue