mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
track transitions more clearly
This commit is contained in:
parent
9f2bc6231f
commit
b96a31db51
2 changed files with 8 additions and 4 deletions
|
@ -54,7 +54,7 @@ const deletePeeksSQL = "" +
|
|||
// we care about all the peeks which were created in this range, deleted in this range,
|
||||
// or were created before this range but haven't been deleted yet.
|
||||
const selectPeeksInRangeSQL = "" +
|
||||
"SELECT room_id, deleted, (id > $3 AND id <= $4) AS new FROM syncapi_peeks WHERE user_id = $1 AND device_id = $2 AND ((id <= $3 AND NOT deleted) OR new)"
|
||||
"SELECT room_id, deleted, (id > $3 AND id <= $4) AS changed FROM syncapi_peeks WHERE user_id = $1 AND device_id = $2 AND ((id <= $3 AND NOT deleted) OR (id > $3 AND id <= $4))"
|
||||
|
||||
const selectPeekingDevicesSQL = "" +
|
||||
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
||||
|
@ -137,9 +137,11 @@ func (s *peekStatements) SelectPeeksInRange(
|
|||
|
||||
for rows.Next() {
|
||||
peek := types.Peek{}
|
||||
if err = rows.Scan(&peek.RoomID, &peek.Deleted, &peek.New); err != nil {
|
||||
var changed bool
|
||||
if err = rows.Scan(&peek.RoomID, &peek.Deleted, &changed); err != nil {
|
||||
return
|
||||
}
|
||||
peek.New = changed && !peek.Deleted
|
||||
peeks = append(peeks, peek)
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ const deletePeeksSQL = "" +
|
|||
// we care about all the peeks which were created in this range, deleted in this range,
|
||||
// or were created before this range but haven't been deleted yet.
|
||||
const selectPeeksInRangeSQL = "" +
|
||||
"SELECT room_id, deleted, (id > $3 AND id <= $4) AS new FROM syncapi_peeks WHERE user_id = $1 AND device_id = $2 AND ((id <= $3 AND NOT deleted) OR new)"
|
||||
"SELECT room_id, deleted, (id > $3 AND id <= $4) AS changed FROM syncapi_peeks WHERE user_id = $1 AND device_id = $2 AND ((id <= $3 AND NOT deleted) OR (id > $3 AND id <= $4))"
|
||||
|
||||
const selectPeekingDevicesSQL = "" +
|
||||
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
||||
|
@ -148,9 +148,11 @@ func (s *peekStatements) SelectPeeksInRange(
|
|||
|
||||
for rows.Next() {
|
||||
peek := types.Peek{}
|
||||
if err = rows.Scan(&peek.RoomID, &peek.Deleted, &peek.New); err != nil {
|
||||
var changed bool
|
||||
if err = rows.Scan(&peek.RoomID, &peek.Deleted, &changed); err != nil {
|
||||
return
|
||||
}
|
||||
peek.New = changed && !peek.Deleted
|
||||
peeks = append(peeks, peek)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue