Documentation
¶
Index ¶
- func CantWriteNew(userId uint64, maxCount int64) bool
- func Create(entity *Entity) error
- func DecrementLike(entity Entity) int64
- func DecrementPostFast(topicId uint64, posters []Poster, lastPostID uint64, lastPostedAt time.Time) error
- func Delete(entity *Entity) int64
- func GetMapByIds(ids []uint64) map[uint64]Entity
- func GetMaxId() uint64
- func GetPointerMapByIds(ids []uint64) map[uint64]*Entity
- func IncrementLike(entity Entity) int64
- func IncrementPostFast(topicId uint64, posters []Poster, lastPostID uint64, lastPostedAt time.Time) error
- func IncrementPostFastWithDB(db *gorm.DB, topicId uint64, posters []Poster, lastPostID uint64, ...) error
- func IncrementViews(counts map[uint64]uint64) error
- func MaxRankingID(ctx context.Context) (uint64, error)
- func PageForAdmin(q AdminPageQuery) struct{ ... }
- func PageForModeration(q ModerationPageQuery) struct{ ... }
- func RankingIDsAfter(ctx context.Context, cursor, upper uint64, limit int) ([]uint64, error)
- func ReservePostSequence(topicId uint64) (uint64, error)
- func ReservePostSequenceWithDB(db *gorm.DB, topicId uint64) (uint64, error)
- func Save(entity *Entity) error
- func SaveNoUpdate(entity *Entity) error
- func SaveOrCreateById(entity *Entity) int64
- func SaveRankScore(ctx context.Context, id uint64, score int64) error
- func SaveWithDB(db *gorm.DB, entity *Entity) error
- func SetPublishedAt(ctx context.Context, id uint64, at time.Time) error
- func UpdatePinWeight(id uint64, pinWeight int) error
- func UpdateProcessStatus(id uint64, processStatus int8) error
- type AdminPageQuery
- type Entity
- func Get(id uint64) (entity Entity)
- func GetDraftsByUserId(userId uint64, limit int) ([]*Entity, error)
- func GetForAdmin(id uint64) (entity Entity)
- func GetForRanking(ctx context.Context, id uint64) (Entity, error)
- func GetLatestPublished(limit int) (entities []*Entity, err error)
- func GetLatestPublishedByUserId(userId uint64, limit int) ([]*Entity, error)
- func GetLatestPublishedByUserIdForAudience(userId uint64, limit int, readableCategoryIDs []uint64, filterAudience bool) ([]*Entity, error)
- func GetLatestPublishedForAudience(limit int, readableCategoryIDs []uint64, filterAudience bool) (entities []*Entity, err error)
- func GetPublishedByUserBeforeId(userId uint64, beforeId uint64, limit int) ([]*Entity, error)
- func GetPublishedByUserBeforeIdForAudience(userId uint64, beforeId uint64, limit int, readableCategoryIDs []uint64, ...) ([]*Entity, error)
- func GetSimple(id any) (entity Entity)
- func QueryById(startId uint64, limit int) (entities []*Entity)
- type ModerationPageQuery
- type PageQuery
- type Poster
- type TopicPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CantWriteNew ¶
func DecrementLike ¶
func DecrementPostFast ¶
func GetMapByIds ¶
func GetPointerMapByIds ¶
func IncrementLike ¶
func IncrementPostFast ¶
func IncrementPostFastWithDB ¶ added in v0.2.61
func IncrementViews ¶
func PageForAdmin ¶
func PageForAdmin(q AdminPageQuery) struct { Page int PageSize int HasNext bool Data []Entity }
func PageForModeration ¶
func RankingIDsAfter ¶ added in v0.2.74
func ReservePostSequence ¶
func ReservePostSequenceWithDB ¶ added in v0.2.61
func SaveNoUpdate ¶
func SaveOrCreateById ¶
func SaveRankScore ¶ added in v0.2.74
These writes deliberately use a table/map, bypassing read-only entity fields.
func SaveWithDB ¶ added in v0.2.74
SaveWithDB leaves event publication to the caller after its transaction commits.
func SetPublishedAt ¶ added in v0.2.74
func UpdatePinWeight ¶
func UpdateProcessStatus ¶
Types ¶
type AdminPageQuery ¶
type Entity ¶
type Entity struct {
Id uint64 `` /* 396-byte string literal not displayed */
// Ranking fields are read-only to ordinary model saves: stale topic snapshots
// must never overwrite worker results or the first publication timestamp.
RankScore int64 `gorm:"column:rank_score;type:bigint;not null;default:0;->;index:idx_topics_list_rank,priority:3,sort:desc" json:"-"`
PublishedAt *time.Time `gorm:"column:published_at;->" json:"-"`
Title string `gorm:"column:title;type:varchar(512);not null;default:'';" json:"title"`
CategoryIds []uint64 `gorm:"column:category_id;type:varchar(255);not null;default:'[]';serializer:json" json:"categoryIds"`
// MainCategoryId is CategoryIds[0]. It is the only category that decides who
// may read the topic. Remaining categories are public auxiliary tags; a
// restricted category must be the topic's only category.
MainCategoryId uint64 `gorm:"column:main_category_id;type:bigint unsigned;not null;default:0;index:idx_topics_main_category;" json:"mainCategoryId"`
UserId uint64 `` /* 160-byte string literal not displayed */
Status int8 `` /* 264-byte string literal not displayed */
ProcessStatus int8 `` /* 279-byte string literal not displayed */
ModerationStatus string `` /* 131-byte string literal not displayed */
ModerationVersion uint64 `gorm:"column:moderation_version;type:bigint unsigned;not null;default:0" json:"-"`
ModerationReason string `gorm:"column:moderation_reason;type:varchar(512);not null;default:''" json:"-"`
ModeratedAt *time.Time `gorm:"column:moderated_at" json:"-"`
LikeCount uint64 `gorm:"column:like_count;type:bigint unsigned;not null;default:0;" json:"likeCount"`
ViewCount uint64 `` /* 133-byte string literal not displayed */
PostCount uint64 `gorm:"column:post_count;type:bigint unsigned;not null;default:0;" json:"postCount"`
ReplyCount uint64 `gorm:"column:reply_count;type:bigint unsigned;not null;default:0;" json:"replyCount"`
PostSeq uint64 `gorm:"column:post_seq;type:bigint unsigned;not null;default:0;" json:"postSeq"`
FirstPostId uint64 `gorm:"column:first_post_id;type:bigint unsigned;not null;default:0;" json:"firstPostId"`
LastPostId uint64 `gorm:"column:last_post_id;type:bigint unsigned;not null;default:0;" json:"lastPostId"`
LastPostedAt *time.Time `gorm:"column:last_posted_at;index:idx_topics_last_posted,sort:desc;" json:"lastPostedAt"`
PinWeight int `` /* 224-byte string literal not displayed */
Excerpt string `gorm:"column:excerpt;type:varchar(255);not null;default:'';" json:"excerpt"`
FirstImageURL string `gorm:"column:first_image_url;type:varchar(512);not null;default:'';" json:"firstImageUrl"`
Posters []Poster `gorm:"column:posters;type:text;serializer:json" json:"posters"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;<-:create;index:idx_topics_list_new,priority:3,sort:desc;" json:"createdAt"`
UpdatedAt time.Time `` /* 246-byte string literal not displayed */
DeletedAt gorm.DeletedAt `json:"-"`
}
func GetForAdmin ¶ added in v0.2.75
func GetForRanking ¶ added in v0.2.74
GetForRanking includes hidden/deleted topics so their scores can settle. Old decimal scores are not read during conversion to integer ranking.
func GetLatestPublished ¶
func GetLatestPublishedByUserIdForAudience ¶ added in v0.2.61
func GetLatestPublishedForAudience ¶ added in v0.2.61
func GetPublishedByUserBeforeIdForAudience ¶ added in v0.2.61
func (*Entity) GetPosters ¶
type ModerationPageQuery ¶
Click to show internal directories.
Click to hide internal directories.