feat(backend): add EPUB CFI and percentage to reading progress

Enhance reading progress tracking to support EPUB-specific location data:
- Add epubcfi field to store EPUB Canonical Fragment Identifier
- Add percentage field for normalized position across formats
- Update UpdateReadingProgress API handler to accept new fields
- Modify database queries to persist additional progress metadata

This enables precise position tracking in reflowable EPUB content
where page numbers are insufficient for accurate bookmarking.
This commit is contained in:
2026-04-09 21:16:53 -04:00
parent 20e96e940d
commit 051ee287c7
2 changed files with 8 additions and 2 deletions
+2
View File
@@ -9579,6 +9579,8 @@ type UpdateReadingProgressParams struct {
UserID pgtype.UUID `db:"user_id" json:"user_id"`
CurrentPage pgtype.Int4 `db:"current_page" json:"current_page"`
TotalPages pgtype.Int4 `db:"total_pages" json:"total_pages"`
Epubcfi string `json:"epubcfi"`
Percentage float64 `json:"percentage"`
}
func (q *Queries) UpdateReadingProgress(ctx context.Context, arg UpdateReadingProgressParams) (ReadingProgress, error) {
+6 -2
View File
@@ -921,8 +921,10 @@ func (mh *MediaHandler) UpdateMediaReadingProgress(c *echo.Context) error {
}
var req struct {
CurrentPage int32 `json:"current_page"`
TotalPages int32 `json:"total_pages"`
CurrentPage int32 `json:"current_page"`
TotalPages int32 `json:"total_pages"`
Epubcfi string `json:"epubcfi"`
Percentage float64 `json:"percentage"`
}
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})
@@ -936,6 +938,8 @@ func (mh *MediaHandler) UpdateMediaReadingProgress(c *echo.Context) error {
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
CurrentPage: pgtype.Int4{Int32: req.CurrentPage, Valid: true},
TotalPages: pgtype.Int4{Int32: req.TotalPages, Valid: req.TotalPages > 0},
Epubcfi: req.Epubcfi,
Percentage: req.Percentage,
})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})