Improve tasks and backdate insights
This commit is contained in:
@@ -2375,7 +2375,7 @@ def _refresh_conversation_stability(conversation, user, person):
|
||||
session__identifier__in=identifiers,
|
||||
)
|
||||
.order_by("ts")
|
||||
.values("ts", "sender_uuid", "session__identifier__service")
|
||||
.values("ts", "sender_uuid", "custom_author", "session__identifier__service")
|
||||
)
|
||||
if not rows:
|
||||
conversation.stability_state = WorkspaceConversation.StabilityState.CALIBRATING
|
||||
@@ -2446,7 +2446,13 @@ def _refresh_conversation_stability(conversation, user, person):
|
||||
for row in rows:
|
||||
ts = int(row["ts"] or 0)
|
||||
sender = str(row.get("sender_uuid") or "").strip()
|
||||
is_inbound = sender in identifier_values
|
||||
author = str(row.get("custom_author") or "").strip().upper()
|
||||
if author in {"USER", "BOT"}:
|
||||
is_inbound = False
|
||||
elif author == "OTHER":
|
||||
is_inbound = True
|
||||
else:
|
||||
is_inbound = sender in identifier_values
|
||||
direction = "in" if is_inbound else "out"
|
||||
day_key = datetime.fromtimestamp(ts / 1000, tz=timezone.utc).date().isoformat()
|
||||
daily_counts[day_key] = daily_counts.get(day_key, 0) + 1
|
||||
|
||||
Reference in New Issue
Block a user