feat(db): locator columns for tombstoned annotations
GetTombstonedAnnotationsForBook now also returns each tombstone's start_position/end_position and epubcfi_start/end (note: position/ epubcfi_location, bookmark: position/cfi_position), so serving code can resolve a device-native locator for deletions of web-created annotations, whose device_sync_data carries no pos0.
This commit is contained in:
@@ -6852,7 +6852,11 @@ SELECT
|
|||||||
mh.dedup_key,
|
mh.dedup_key,
|
||||||
'highlight' as annotation_type,
|
'highlight' as annotation_type,
|
||||||
mh.device_sync_data,
|
mh.device_sync_data,
|
||||||
mh.deleted_at
|
mh.deleted_at,
|
||||||
|
mh.start_position,
|
||||||
|
mh.end_position,
|
||||||
|
mh.epubcfi_start,
|
||||||
|
mh.epubcfi_end
|
||||||
FROM media_highlights mh
|
FROM media_highlights mh
|
||||||
WHERE mh.media_item_id = $1 AND mh.user_id = $2 AND mh.deleted = TRUE AND mh.deleted_at > $3
|
WHERE mh.media_item_id = $1 AND mh.user_id = $2 AND mh.deleted = TRUE AND mh.deleted_at > $3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -6861,7 +6865,11 @@ SELECT
|
|||||||
mn.dedup_key,
|
mn.dedup_key,
|
||||||
'note' as annotation_type,
|
'note' as annotation_type,
|
||||||
mn.device_sync_data,
|
mn.device_sync_data,
|
||||||
mn.deleted_at
|
mn.deleted_at,
|
||||||
|
mn.position as start_position,
|
||||||
|
NULL as end_position,
|
||||||
|
mn.epubcfi_location as epubcfi_start,
|
||||||
|
NULL as epubcfi_end
|
||||||
FROM media_notes mn
|
FROM media_notes mn
|
||||||
WHERE mn.media_item_id = $1 AND mn.user_id = $2 AND mn.deleted = TRUE AND mn.deleted_at > $3
|
WHERE mn.media_item_id = $1 AND mn.user_id = $2 AND mn.deleted = TRUE AND mn.deleted_at > $3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -6870,7 +6878,11 @@ SELECT
|
|||||||
mb.dedup_key,
|
mb.dedup_key,
|
||||||
'bookmark' as annotation_type,
|
'bookmark' as annotation_type,
|
||||||
mb.device_sync_data,
|
mb.device_sync_data,
|
||||||
mb.deleted_at
|
mb.deleted_at,
|
||||||
|
mb.position as start_position,
|
||||||
|
NULL as end_position,
|
||||||
|
mb.cfi_position as epubcfi_start,
|
||||||
|
NULL as epubcfi_end
|
||||||
FROM media_bookmarks mb
|
FROM media_bookmarks mb
|
||||||
WHERE mb.media_item_id = $1 AND mb.user_id = $2 AND mb.deleted = TRUE AND mb.deleted_at > $3
|
WHERE mb.media_item_id = $1 AND mb.user_id = $2 AND mb.deleted = TRUE AND mb.deleted_at > $3
|
||||||
ORDER BY deleted_at DESC
|
ORDER BY deleted_at DESC
|
||||||
@@ -6888,6 +6900,10 @@ type GetTombstonedAnnotationsForBookRow struct {
|
|||||||
AnnotationType string `db:"annotation_type" json:"annotation_type"`
|
AnnotationType string `db:"annotation_type" json:"annotation_type"`
|
||||||
DeviceSyncData []byte `db:"device_sync_data" json:"device_sync_data"`
|
DeviceSyncData []byte `db:"device_sync_data" json:"device_sync_data"`
|
||||||
DeletedAt pgtype.Timestamptz `db:"deleted_at" json:"deleted_at"`
|
DeletedAt pgtype.Timestamptz `db:"deleted_at" json:"deleted_at"`
|
||||||
|
StartPosition pgtype.Text `db:"start_position" json:"start_position"`
|
||||||
|
EndPosition pgtype.Text `db:"end_position" json:"end_position"`
|
||||||
|
EpubcfiStart pgtype.Text `db:"epubcfi_start" json:"epubcfi_start"`
|
||||||
|
EpubcfiEnd pgtype.Text `db:"epubcfi_end" json:"epubcfi_end"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetTombstonedAnnotationsForBook(ctx context.Context, arg GetTombstonedAnnotationsForBookParams) ([]GetTombstonedAnnotationsForBookRow, error) {
|
func (q *Queries) GetTombstonedAnnotationsForBook(ctx context.Context, arg GetTombstonedAnnotationsForBookParams) ([]GetTombstonedAnnotationsForBookRow, error) {
|
||||||
@@ -6905,6 +6921,10 @@ func (q *Queries) GetTombstonedAnnotationsForBook(ctx context.Context, arg GetTo
|
|||||||
&i.AnnotationType,
|
&i.AnnotationType,
|
||||||
&i.DeviceSyncData,
|
&i.DeviceSyncData,
|
||||||
&i.DeletedAt,
|
&i.DeletedAt,
|
||||||
|
&i.StartPosition,
|
||||||
|
&i.EndPosition,
|
||||||
|
&i.EpubcfiStart,
|
||||||
|
&i.EpubcfiEnd,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -992,7 +992,11 @@ SELECT
|
|||||||
mh.dedup_key,
|
mh.dedup_key,
|
||||||
'highlight' as annotation_type,
|
'highlight' as annotation_type,
|
||||||
mh.device_sync_data,
|
mh.device_sync_data,
|
||||||
mh.deleted_at
|
mh.deleted_at,
|
||||||
|
mh.start_position,
|
||||||
|
mh.end_position,
|
||||||
|
mh.epubcfi_start,
|
||||||
|
mh.epubcfi_end
|
||||||
FROM media_highlights mh
|
FROM media_highlights mh
|
||||||
WHERE mh.media_item_id = $1 AND mh.user_id = $2 AND mh.deleted = TRUE AND mh.deleted_at > $3
|
WHERE mh.media_item_id = $1 AND mh.user_id = $2 AND mh.deleted = TRUE AND mh.deleted_at > $3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -1001,7 +1005,11 @@ SELECT
|
|||||||
mn.dedup_key,
|
mn.dedup_key,
|
||||||
'note' as annotation_type,
|
'note' as annotation_type,
|
||||||
mn.device_sync_data,
|
mn.device_sync_data,
|
||||||
mn.deleted_at
|
mn.deleted_at,
|
||||||
|
mn.position as start_position,
|
||||||
|
NULL as end_position,
|
||||||
|
mn.epubcfi_location as epubcfi_start,
|
||||||
|
NULL as epubcfi_end
|
||||||
FROM media_notes mn
|
FROM media_notes mn
|
||||||
WHERE mn.media_item_id = $1 AND mn.user_id = $2 AND mn.deleted = TRUE AND mn.deleted_at > $3
|
WHERE mn.media_item_id = $1 AND mn.user_id = $2 AND mn.deleted = TRUE AND mn.deleted_at > $3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -1010,7 +1018,11 @@ SELECT
|
|||||||
mb.dedup_key,
|
mb.dedup_key,
|
||||||
'bookmark' as annotation_type,
|
'bookmark' as annotation_type,
|
||||||
mb.device_sync_data,
|
mb.device_sync_data,
|
||||||
mb.deleted_at
|
mb.deleted_at,
|
||||||
|
mb.position as start_position,
|
||||||
|
NULL as end_position,
|
||||||
|
mb.cfi_position as epubcfi_start,
|
||||||
|
NULL as epubcfi_end
|
||||||
FROM media_bookmarks mb
|
FROM media_bookmarks mb
|
||||||
WHERE mb.media_item_id = $1 AND mb.user_id = $2 AND mb.deleted = TRUE AND mb.deleted_at > $3
|
WHERE mb.media_item_id = $1 AND mb.user_id = $2 AND mb.deleted = TRUE AND mb.deleted_at > $3
|
||||||
ORDER BY deleted_at DESC;
|
ORDER BY deleted_at DESC;
|
||||||
|
|||||||
Reference in New Issue
Block a user