You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow up to my last question. I have no logical programming background and I'm trying to piece this together.
I have a table of summarie, where each summary is a summary of multiple messages. It includes the UUID of the last message that was summarized. I want to retrieve all messages that have been sent since my latest summary.
Here's the resultant query. It works. Is this the right way to think about these things, or am I going about this the wrong way? Also, is there a better place to ask these questions?
%%cozo
# Get our summaries
sums[id, summary, timestamp, last_message] := *summaries{id, summary, first_message, last_message, timestamp, metadata}
# Get the UUID of the last message from the most recent summary
res[count, last_message] <~ ReorderSort(
sums[id, summary, timestamp, last_message],
out: [last_message],
sort_by: timestamp,
descending: true,
take: 1
)
# Get the timestamp of the last message that contains this ID
time[id, timestamp] := *messages{id, source, message, timestamp, metadata}, res[cnt, lst_msg], eq(id, lst_msg)
# Get all messages with a timestamp greater than the last message's timestamp
?[id, source, message, timestamp, metadata] := *messages{id, source, message, timestamp, metadata}, time[t_id, ts], gt(timestamp, ts)
:order timestamp
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Follow up to my last question. I have no logical programming background and I'm trying to piece this together.
I have a table of summarie, where each summary is a summary of multiple messages. It includes the UUID of the last message that was summarized. I want to retrieve all messages that have been sent since my latest summary.
Here's the resultant query. It works. Is this the right way to think about these things, or am I going about this the wrong way? Also, is there a better place to ask these questions?
Beta Was this translation helpful? Give feedback.
All reactions