// Package hn implements the orangesite Hacker News front-page scraper, its // gorm-backed storage schema, and the HTTP handlers that render it. package hn import ( "time" "github.com/jinzhu/gorm" ) // this schema is quite redundant, i know // HNFrontPage records a story's tenure on the front page: when it appeared, // when it disappeared, and the best rank it reached. The HN-prefixed name is // retained deliberately: gorm derives the table name ("hn_front_pages") from // it, so renaming would orphan the existing production database. // //nolint:revive // see above: renaming changes the gorm table name type HNFrontPage struct { gorm.Model InternalID uint64 HNID uint // HN integer id Appeared time.Time Disappeared time.Time HighestRank uint // frontpage index Rank uint // frontpage index Title string // submission title Score uint // updoots URL string // duh } // HNStoryRank is a point-in-time snapshot of a single story's rank. The // HN-prefixed name is retained deliberately for the same gorm table-name // reason as HNFrontPage. // //nolint:revive // renaming changes the gorm table name type HNStoryRank struct { gorm.Model InternalStoryID uint64 HNID uint // HN integer id Title string // submission title URL string // duh Rank uint // frontpage index Score uint // updoots FetchedAt time.Time // identical within fetchid } // FrontPageCache is a cached view of a story's front-page lifetime. type FrontPageCache struct { gorm.Model CacheID uint64 HNID uint HighestRankReached uint URL string Title string Appeared time.Time Disappeared time.Time }