chore(db): retire the nine dead annotation plain queries + duplicate SQL line
H3 leftover: the annotation handlers route everything through the sync service (dedup/LWW/tombstones), leaving the plain Create/Update/Delete queries for media_notes/media_highlights/media_bookmarks with zero callers repo-wide (handlers, services, tests). Queries.sql drops them so H4's row work doesn't carry dead weight; sqlc regen compiles clean, proving nothing referenced the generated stubs. Also removes the literal duplicate `AND mi.missing_scan_count = 0` line in the library-stats query (harmless but confusing).
This commit is contained in:
1 parent
edb4e60679
commit
00305ffc7b
3 files changed
+4
-434
No files matched your search
@@ -703,60 +703,6 @@ func (q *Queries) CreateLibrary(ctx context.Context, arg CreateLibraryParams) (L
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaBookmark = `-- name: CreateMediaBookmark :one
|
||||
INSERT INTO media_bookmarks (media_item_id, user_id, page_number, chapter_number, cfi_position, title, position, notes)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, media_item_id, user_id, page_number, chapter_number, cfi_position, title, position, notes, created_at, dedup_key, last_modified_at, last_modified_source, device_sync_data, percentage_location, epubcfi_location, chapter_reference, deleted, deleted_at, origin_source
|
||||
`
|
||||
|
||||
type CreateMediaBookmarkParams struct {
|
||||
MediaItemID pgtype.UUID `db:"media_item_id" json:"media_item_id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
PageNumber pgtype.Int4 `db:"page_number" json:"page_number"`
|
||||
ChapterNumber pgtype.Int4 `db:"chapter_number" json:"chapter_number"`
|
||||
CfiPosition pgtype.Text `db:"cfi_position" json:"cfi_position"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Position pgtype.Text `db:"position" json:"position"`
|
||||
Notes pgtype.Text `db:"notes" json:"notes"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateMediaBookmark(ctx context.Context, arg CreateMediaBookmarkParams) (MediaBookmarks, error) {
|
||||
row := q.db.QueryRow(ctx, CreateMediaBookmark,
|
||||
arg.MediaItemID,
|
||||
arg.UserID,
|
||||
arg.PageNumber,
|
||||
arg.ChapterNumber,
|
||||
arg.CfiPosition,
|
||||
arg.Title,
|
||||
arg.Position,
|
||||
arg.Notes,
|
||||
)
|
||||
var i MediaBookmarks
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.PageNumber,
|
||||
&i.ChapterNumber,
|
||||
&i.CfiPosition,
|
||||
&i.Title,
|
||||
&i.Position,
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.DeviceSyncData,
|
||||
&i.PercentageLocation,
|
||||
&i.EpubcfiLocation,
|
||||
&i.ChapterReference,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
&i.OriginSource,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaBookmarkFull = `-- name: CreateMediaBookmarkFull :one
|
||||
INSERT INTO media_bookmarks (
|
||||
media_item_id, user_id, page_number, chapter_number,
|
||||
@@ -833,66 +779,6 @@ func (q *Queries) CreateMediaBookmarkFull(ctx context.Context, arg CreateMediaBo
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaHighlight = `-- name: CreateMediaHighlight :one
|
||||
INSERT INTO media_highlights (media_item_id, user_id, selection_text, start_position, end_position, color, note_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING id, media_item_id, user_id, selection_text, start_position, end_position, color, note_id, created_at, updated_at, percentage_start, percentage_end, character_start, character_end, epubcfi_start, epubcfi_end, chapter_reference, paragraph_start, paragraph_end, panel_number, device_sync_data, dedup_key, last_modified_at, last_modified_source, note_text, deleted, deleted_at
|
||||
`
|
||||
|
||||
type CreateMediaHighlightParams struct {
|
||||
MediaItemID pgtype.UUID `db:"media_item_id" json:"media_item_id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
SelectionText string `db:"selection_text" json:"selection_text"`
|
||||
StartPosition pgtype.Text `db:"start_position" json:"start_position"`
|
||||
EndPosition pgtype.Text `db:"end_position" json:"end_position"`
|
||||
Color pgtype.Text `db:"color" json:"color"`
|
||||
NoteID pgtype.UUID `db:"note_id" json:"note_id"`
|
||||
}
|
||||
|
||||
// Media Highlights queries
|
||||
func (q *Queries) CreateMediaHighlight(ctx context.Context, arg CreateMediaHighlightParams) (MediaHighlights, error) {
|
||||
row := q.db.QueryRow(ctx, CreateMediaHighlight,
|
||||
arg.MediaItemID,
|
||||
arg.UserID,
|
||||
arg.SelectionText,
|
||||
arg.StartPosition,
|
||||
arg.EndPosition,
|
||||
arg.Color,
|
||||
arg.NoteID,
|
||||
)
|
||||
var i MediaHighlights
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.SelectionText,
|
||||
&i.StartPosition,
|
||||
&i.EndPosition,
|
||||
&i.Color,
|
||||
&i.NoteID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.PercentageStart,
|
||||
&i.PercentageEnd,
|
||||
&i.CharacterStart,
|
||||
&i.CharacterEnd,
|
||||
&i.EpubcfiStart,
|
||||
&i.EpubcfiEnd,
|
||||
&i.ChapterReference,
|
||||
&i.ParagraphStart,
|
||||
&i.ParagraphEnd,
|
||||
&i.PanelNumber,
|
||||
&i.DeviceSyncData,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.NoteText,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaHighlightFull = `-- name: CreateMediaHighlightFull :one
|
||||
INSERT INTO media_highlights (
|
||||
media_item_id, user_id, selection_text,
|
||||
@@ -1403,52 +1289,6 @@ func (q *Queries) CreateMediaItemIfNew(ctx context.Context, arg CreateMediaItemI
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaNote = `-- name: CreateMediaNote :one
|
||||
INSERT INTO media_notes (media_item_id, user_id, content, position)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, media_item_id, user_id, content, position, created_at, updated_at, percentage_location, character_start, character_end, epubcfi_location, chapter_reference, paragraph_reference, device_sync_data, dedup_key, last_modified_at, last_modified_source, deleted, deleted_at
|
||||
`
|
||||
|
||||
type CreateMediaNoteParams struct {
|
||||
MediaItemID pgtype.UUID `db:"media_item_id" json:"media_item_id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
Content string `db:"content" json:"content"`
|
||||
Position pgtype.Text `db:"position" json:"position"`
|
||||
}
|
||||
|
||||
// Media Notes queries
|
||||
func (q *Queries) CreateMediaNote(ctx context.Context, arg CreateMediaNoteParams) (MediaNotes, error) {
|
||||
row := q.db.QueryRow(ctx, CreateMediaNote,
|
||||
arg.MediaItemID,
|
||||
arg.UserID,
|
||||
arg.Content,
|
||||
arg.Position,
|
||||
)
|
||||
var i MediaNotes
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.Content,
|
||||
&i.Position,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.PercentageLocation,
|
||||
&i.CharacterStart,
|
||||
&i.CharacterEnd,
|
||||
&i.EpubcfiLocation,
|
||||
&i.ChapterReference,
|
||||
&i.ParagraphReference,
|
||||
&i.DeviceSyncData,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const CreateMediaNoteFull = `-- name: CreateMediaNoteFull :one
|
||||
INSERT INTO media_notes (
|
||||
media_item_id, user_id, content, position,
|
||||
@@ -2215,35 +2055,6 @@ func (q *Queries) DeleteLibraryFolder(ctx context.Context, arg DeleteLibraryFold
|
||||
return i, err
|
||||
}
|
||||
|
||||
const DeleteMediaBookmark = `-- name: DeleteMediaBookmark :exec
|
||||
DELETE FROM media_bookmarks
|
||||
WHERE id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type DeleteMediaBookmarkParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteMediaBookmark(ctx context.Context, arg DeleteMediaBookmarkParams) error {
|
||||
_, err := q.db.Exec(ctx, DeleteMediaBookmark, arg.ID, arg.UserID)
|
||||
return err
|
||||
}
|
||||
|
||||
const DeleteMediaHighlight = `-- name: DeleteMediaHighlight :exec
|
||||
DELETE FROM media_highlights WHERE id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type DeleteMediaHighlightParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteMediaHighlight(ctx context.Context, arg DeleteMediaHighlightParams) error {
|
||||
_, err := q.db.Exec(ctx, DeleteMediaHighlight, arg.ID, arg.UserID)
|
||||
return err
|
||||
}
|
||||
|
||||
const DeleteMediaItem = `-- name: DeleteMediaItem :exec
|
||||
DELETE FROM media_items WHERE id = $1
|
||||
`
|
||||
@@ -2263,20 +2074,6 @@ func (q *Queries) DeleteMediaItemFormat(ctx context.Context, id pgtype.UUID) err
|
||||
return err
|
||||
}
|
||||
|
||||
const DeleteMediaNote = `-- name: DeleteMediaNote :exec
|
||||
DELETE FROM media_notes WHERE id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type DeleteMediaNoteParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteMediaNote(ctx context.Context, arg DeleteMediaNoteParams) error {
|
||||
_, err := q.db.Exec(ctx, DeleteMediaNote, arg.ID, arg.UserID)
|
||||
return err
|
||||
}
|
||||
|
||||
const DeleteMediaRating = `-- name: DeleteMediaRating :exec
|
||||
DELETE FROM media_ratings WHERE media_item_id = $1 AND user_id = $2
|
||||
`
|
||||
@@ -5488,6 +5285,7 @@ const GetMediaHighlight = `-- name: GetMediaHighlight :one
|
||||
SELECT id, media_item_id, user_id, selection_text, start_position, end_position, color, note_id, created_at, updated_at, percentage_start, percentage_end, character_start, character_end, epubcfi_start, epubcfi_end, chapter_reference, paragraph_start, paragraph_end, panel_number, device_sync_data, dedup_key, last_modified_at, last_modified_source, note_text, deleted, deleted_at FROM media_highlights WHERE id = $1
|
||||
`
|
||||
|
||||
// Media Highlights queries
|
||||
func (q *Queries) GetMediaHighlight(ctx context.Context, id pgtype.UUID) (MediaHighlights, error) {
|
||||
row := q.db.QueryRow(ctx, GetMediaHighlight, id)
|
||||
var i MediaHighlights
|
||||
@@ -6760,6 +6558,7 @@ const GetMediaNote = `-- name: GetMediaNote :one
|
||||
SELECT id, media_item_id, user_id, content, position, created_at, updated_at, percentage_location, character_start, character_end, epubcfi_location, chapter_reference, paragraph_reference, device_sync_data, dedup_key, last_modified_at, last_modified_source, deleted, deleted_at FROM media_notes WHERE id = $1
|
||||
`
|
||||
|
||||
// Media Notes queries
|
||||
func (q *Queries) GetMediaNote(ctx context.Context, id pgtype.UUID) (MediaNotes, error) {
|
||||
row := q.db.QueryRow(ctx, GetMediaNote, id)
|
||||
var i MediaNotes
|
||||
@@ -14059,59 +13858,6 @@ func (q *Queries) UpdateLibrary(ctx context.Context, arg UpdateLibraryParams) (L
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaBookmark = `-- name: UpdateMediaBookmark :one
|
||||
UPDATE media_bookmarks
|
||||
SET
|
||||
title = $2,
|
||||
notes = $3,
|
||||
position = $4,
|
||||
last_modified_at = NOW()
|
||||
WHERE id = $1 AND user_id = $5
|
||||
RETURNING id, media_item_id, user_id, page_number, chapter_number, cfi_position, title, position, notes, created_at, dedup_key, last_modified_at, last_modified_source, device_sync_data, percentage_location, epubcfi_location, chapter_reference, deleted, deleted_at, origin_source
|
||||
`
|
||||
|
||||
type UpdateMediaBookmarkParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Notes pgtype.Text `db:"notes" json:"notes"`
|
||||
Position pgtype.Text `db:"position" json:"position"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateMediaBookmark(ctx context.Context, arg UpdateMediaBookmarkParams) (MediaBookmarks, error) {
|
||||
row := q.db.QueryRow(ctx, UpdateMediaBookmark,
|
||||
arg.ID,
|
||||
arg.Title,
|
||||
arg.Notes,
|
||||
arg.Position,
|
||||
arg.UserID,
|
||||
)
|
||||
var i MediaBookmarks
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.PageNumber,
|
||||
&i.ChapterNumber,
|
||||
&i.CfiPosition,
|
||||
&i.Title,
|
||||
&i.Position,
|
||||
&i.Notes,
|
||||
&i.CreatedAt,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.DeviceSyncData,
|
||||
&i.PercentageLocation,
|
||||
&i.EpubcfiLocation,
|
||||
&i.ChapterReference,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
&i.OriginSource,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaBookmarkForSync = `-- name: UpdateMediaBookmarkForSync :one
|
||||
UPDATE media_bookmarks SET
|
||||
page_number = $2,
|
||||
@@ -14193,71 +13939,6 @@ func (q *Queries) UpdateMediaBookmarkForSync(ctx context.Context, arg UpdateMedi
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaHighlight = `-- name: UpdateMediaHighlight :one
|
||||
UPDATE media_highlights SET
|
||||
selection_text = $2,
|
||||
start_position = $3,
|
||||
end_position = $4,
|
||||
color = $5,
|
||||
note_id = $6,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1 AND user_id = $7
|
||||
RETURNING id, media_item_id, user_id, selection_text, start_position, end_position, color, note_id, created_at, updated_at, percentage_start, percentage_end, character_start, character_end, epubcfi_start, epubcfi_end, chapter_reference, paragraph_start, paragraph_end, panel_number, device_sync_data, dedup_key, last_modified_at, last_modified_source, note_text, deleted, deleted_at
|
||||
`
|
||||
|
||||
type UpdateMediaHighlightParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
SelectionText string `db:"selection_text" json:"selection_text"`
|
||||
StartPosition pgtype.Text `db:"start_position" json:"start_position"`
|
||||
EndPosition pgtype.Text `db:"end_position" json:"end_position"`
|
||||
Color pgtype.Text `db:"color" json:"color"`
|
||||
NoteID pgtype.UUID `db:"note_id" json:"note_id"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateMediaHighlight(ctx context.Context, arg UpdateMediaHighlightParams) (MediaHighlights, error) {
|
||||
row := q.db.QueryRow(ctx, UpdateMediaHighlight,
|
||||
arg.ID,
|
||||
arg.SelectionText,
|
||||
arg.StartPosition,
|
||||
arg.EndPosition,
|
||||
arg.Color,
|
||||
arg.NoteID,
|
||||
arg.UserID,
|
||||
)
|
||||
var i MediaHighlights
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.SelectionText,
|
||||
&i.StartPosition,
|
||||
&i.EndPosition,
|
||||
&i.Color,
|
||||
&i.NoteID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.PercentageStart,
|
||||
&i.PercentageEnd,
|
||||
&i.CharacterStart,
|
||||
&i.CharacterEnd,
|
||||
&i.EpubcfiStart,
|
||||
&i.EpubcfiEnd,
|
||||
&i.ChapterReference,
|
||||
&i.ParagraphStart,
|
||||
&i.ParagraphEnd,
|
||||
&i.PanelNumber,
|
||||
&i.DeviceSyncData,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.NoteText,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaHighlightForSync = `-- name: UpdateMediaHighlightForSync :one
|
||||
UPDATE media_highlights SET
|
||||
selection_text = $2,
|
||||
@@ -14943,54 +14624,6 @@ func (q *Queries) UpdateMediaItemKoboMetadata(ctx context.Context, arg UpdateMed
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaNote = `-- name: UpdateMediaNote :one
|
||||
UPDATE media_notes SET
|
||||
content = $2,
|
||||
position = $3,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1 AND user_id = $4
|
||||
RETURNING id, media_item_id, user_id, content, position, created_at, updated_at, percentage_location, character_start, character_end, epubcfi_location, chapter_reference, paragraph_reference, device_sync_data, dedup_key, last_modified_at, last_modified_source, deleted, deleted_at
|
||||
`
|
||||
|
||||
type UpdateMediaNoteParams struct {
|
||||
ID pgtype.UUID `db:"id" json:"id"`
|
||||
Content string `db:"content" json:"content"`
|
||||
Position pgtype.Text `db:"position" json:"position"`
|
||||
UserID pgtype.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateMediaNote(ctx context.Context, arg UpdateMediaNoteParams) (MediaNotes, error) {
|
||||
row := q.db.QueryRow(ctx, UpdateMediaNote,
|
||||
arg.ID,
|
||||
arg.Content,
|
||||
arg.Position,
|
||||
arg.UserID,
|
||||
)
|
||||
var i MediaNotes
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.MediaItemID,
|
||||
&i.UserID,
|
||||
&i.Content,
|
||||
&i.Position,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.PercentageLocation,
|
||||
&i.CharacterStart,
|
||||
&i.CharacterEnd,
|
||||
&i.EpubcfiLocation,
|
||||
&i.ChapterReference,
|
||||
&i.ParagraphReference,
|
||||
&i.DeviceSyncData,
|
||||
&i.DedupKey,
|
||||
&i.LastModifiedAt,
|
||||
&i.LastModifiedSource,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const UpdateMediaNoteForSync = `-- name: UpdateMediaNoteForSync :one
|
||||
UPDATE media_notes SET
|
||||
content = $2,
|
||||
|
||||
Reference in new issue
Block a user