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:
@@ -9579,6 +9579,8 @@ type UpdateReadingProgressParams struct {
|
|||||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||||
CurrentPage pgtype.Int4 `db:"current_page" json:"current_page"`
|
CurrentPage pgtype.Int4 `db:"current_page" json:"current_page"`
|
||||||
TotalPages pgtype.Int4 `db:"total_pages" json:"total_pages"`
|
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) {
|
func (q *Queries) UpdateReadingProgress(ctx context.Context, arg UpdateReadingProgressParams) (ReadingProgress, error) {
|
||||||
|
|||||||
@@ -921,8 +921,10 @@ func (mh *MediaHandler) UpdateMediaReadingProgress(c *echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
CurrentPage int32 `json:"current_page"`
|
CurrentPage int32 `json:"current_page"`
|
||||||
TotalPages int32 `json:"total_pages"`
|
TotalPages int32 `json:"total_pages"`
|
||||||
|
Epubcfi string `json:"epubcfi"`
|
||||||
|
Percentage float64 `json:"percentage"`
|
||||||
}
|
}
|
||||||
if err := c.Bind(&req); err != nil {
|
if err := c.Bind(&req); err != nil {
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})
|
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},
|
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
||||||
CurrentPage: pgtype.Int4{Int32: req.CurrentPage, Valid: true},
|
CurrentPage: pgtype.Int4{Int32: req.CurrentPage, Valid: true},
|
||||||
TotalPages: pgtype.Int4{Int32: req.TotalPages, Valid: req.TotalPages > 0},
|
TotalPages: pgtype.Int4{Int32: req.TotalPages, Valid: req.TotalPages > 0},
|
||||||
|
Epubcfi: req.Epubcfi,
|
||||||
|
Percentage: req.Percentage,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||||
|
|||||||
Reference in New Issue
Block a user