mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-04-18 11:16:55 +00:00
feat: add change_seq to transcripts for ingestion support (#868)
* feat: add change_seq to transcripts for ingestion support Add a monotonically increasing change_seq column to the transcript table, backed by a PostgreSQL sequence and BEFORE INSERT OR UPDATE trigger. Every mutation gets a new sequence value, letting external ingesters checkpoint and never miss an update. * chore: regenerate frontend API types
This commit is contained in:
@@ -111,6 +111,7 @@ class GetTranscriptMinimal(BaseModel):
|
||||
room_id: str | None = None
|
||||
room_name: str | None = None
|
||||
audio_deleted: bool | None = None
|
||||
change_seq: int | None = None
|
||||
|
||||
|
||||
class TranscriptParticipantWithEmail(TranscriptParticipant):
|
||||
@@ -266,12 +267,22 @@ async def transcripts_list(
|
||||
source_kind: SourceKind | None = None,
|
||||
room_id: str | None = None,
|
||||
search_term: str | None = None,
|
||||
change_seq_from: int | None = None,
|
||||
sort_by: Literal["created_at", "change_seq"] | None = None,
|
||||
):
|
||||
if not user and not settings.PUBLIC_MODE:
|
||||
raise HTTPException(status_code=401, detail="Not authenticated")
|
||||
|
||||
user_id = user["sub"] if user else None
|
||||
|
||||
# Default behavior preserved: sort_by=None → "-created_at"
|
||||
if sort_by == "change_seq":
|
||||
order_by = "change_seq" # ASC (ascending for checkpoint-based polling)
|
||||
elif sort_by == "created_at":
|
||||
order_by = "-created_at" # DESC (newest first, same as current default)
|
||||
else:
|
||||
order_by = "-created_at" # default, backward compatible
|
||||
|
||||
return await apaginate(
|
||||
get_database(),
|
||||
await transcripts_controller.get_all(
|
||||
@@ -279,7 +290,8 @@ async def transcripts_list(
|
||||
source_kind=SourceKind(source_kind) if source_kind else None,
|
||||
room_id=room_id,
|
||||
search_term=search_term,
|
||||
order_by="-created_at",
|
||||
order_by=order_by,
|
||||
change_seq_from=change_seq_from,
|
||||
return_query=True,
|
||||
),
|
||||
)
|
||||
@@ -512,6 +524,7 @@ async def transcript_get(
|
||||
"room_id": transcript.room_id,
|
||||
"room_name": room_name,
|
||||
"audio_deleted": transcript.audio_deleted,
|
||||
"change_seq": transcript.change_seq,
|
||||
"participants": participants,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user