fix: store time as timestamp_ms

This commit is contained in:
Stephen Zhou 2025-06-13 12:39:18 +08:00
parent c6fb520975
commit 711b0f14ac
No known key found for this signature in database
2 changed files with 3 additions and 6 deletions

View File

@ -93,8 +93,8 @@ export const entriesTable = sqliteTable("entries", {
author: text("author"),
authorUrl: text("author_url"),
authorAvatar: text("author_avatar"),
insertedAt: integer("inserted_at", { mode: "timestamp" }).notNull(),
publishedAt: integer("published_at", { mode: "timestamp" }).notNull(),
insertedAt: integer("inserted_at", { mode: "timestamp_ms" }).notNull(),
publishedAt: integer("published_at", { mode: "timestamp_ms" }).notNull(),
media: text("media", { mode: "json" }).$type<MediaModel[]>(),
categories: text("categories", { mode: "json" }).$type<string[]>(),
attachments: text("attachments", { mode: "json" }).$type<AttachmentsModel[]>(),

View File

@ -89,10 +89,7 @@ function sortEntryIdsByPublishDate(a: string, b: string) {
const entryA = getEntry(a)
const entryB = getEntry(b)
if (!entryA || !entryB) return 0
return (
entryB.publishedAt.getTime() - entryA.publishedAt.getTime() ||
entryB.insertedAt.getTime() - entryA.insertedAt.getTime()
)
return entryB.publishedAt.getTime() - entryA.publishedAt.getTime()
}
export const useEntryIdsByView = (view: FeedViewType, excludePrivate: boolean) => {