(
filters: BookmarkTimelineFilters = {},
)
| 621 | } |
| 622 | |
| 623 | export async function listBookmarks( |
| 624 | filters: BookmarkTimelineFilters = {}, |
| 625 | ): Promise<BookmarkTimelineItem[]> { |
| 626 | const dbPath = twitterBookmarksIndexPath(); |
| 627 | const db = await openDb(dbPath); |
| 628 | ensureMigrations(db); |
| 629 | const limit = filters.limit ?? 30; |
| 630 | const offset = filters.offset ?? 0; |
| 631 | |
| 632 | try { |
| 633 | const { where, params } = buildBookmarkWhereClause(filters); |
| 634 | const sql = ` |
| 635 | SELECT |
| 636 | b.id, |
| 637 | b.tweet_id, |
| 638 | b.url, |
| 639 | b.text, |
| 640 | b.author_handle, |
| 641 | b.author_name, |
| 642 | b.author_profile_image_url, |
| 643 | b.posted_at, |
| 644 | b.bookmarked_at, |
| 645 | b.categories, |
| 646 | b.primary_category, |
| 647 | b.domains, |
| 648 | b.primary_domain, |
| 649 | b.github_urls, |
| 650 | b.links_json, |
| 651 | b.media_count, |
| 652 | b.link_count, |
| 653 | b.like_count, |
| 654 | b.repost_count, |
| 655 | b.reply_count, |
| 656 | b.quote_count, |
| 657 | b.bookmark_count, |
| 658 | b.view_count, |
| 659 | b.folder_ids, |
| 660 | b.folder_names, |
| 661 | b.article_title, |
| 662 | b.article_text, |
| 663 | b.article_site, |
| 664 | b.synced_at, |
| 665 | b.enriched_at, |
| 666 | b.quoted_status_id, |
| 667 | b.quoted_tweet_json |
| 668 | FROM bookmarks b |
| 669 | ${where} |
| 670 | ${bookmarkSortClause(filters.sort)} |
| 671 | LIMIT ? |
| 672 | OFFSET ? |
| 673 | `; |
| 674 | params.push(limit, offset); |
| 675 | |
| 676 | const rows = db.exec(sql, params); |
| 677 | if (!rows.length) return []; |
| 678 | return rows[0].values.map((row) => mapTimelineRow(row)); |
| 679 | } finally { |
| 680 | db.close(); |
no test coverage detected