mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-28 16:08: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,
|
// 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.
|
// or were created before this range but haven't been deleted yet.
|
||||||
const selectPeeksInRangeSQL = "" +
|
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 = "" +
|
const selectPeekingDevicesSQL = "" +
|
||||||
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
||||||
|
@ -137,9 +137,11 @@ func (s *peekStatements) SelectPeeksInRange(
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
peek := types.Peek{}
|
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
|
return
|
||||||
}
|
}
|
||||||
|
peek.New = changed && !peek.Deleted
|
||||||
peeks = append(peeks, peek)
|
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,
|
// 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.
|
// or were created before this range but haven't been deleted yet.
|
||||||
const selectPeeksInRangeSQL = "" +
|
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 = "" +
|
const selectPeekingDevicesSQL = "" +
|
||||||
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
"SELECT room_id, user_id, device_id FROM syncapi_peeks WHERE deleted=false"
|
||||||
|
@ -148,9 +148,11 @@ func (s *peekStatements) SelectPeeksInRange(
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
peek := types.Peek{}
|
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
|
return
|
||||||
}
|
}
|
||||||
|
peek.New = changed && !peek.Deleted
|
||||||
peeks = append(peeks, peek)
|
peeks = append(peeks, peek)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue