Documentation
¶
Index ¶
- type DailyActivity
- type Store
- func (s *Store) GetDailyActivity(ctx context.Context, months int) ([]DailyActivity, error)
- func (s *Store) GetWritingStats(ctx context.Context, novelCount, chapterCount int64) (*WritingStats, error)
- func (s *Store) LogChanges(ctx context.Context, novelID, chapterID int64, added, deleted int)
- func (s *Store) LogDelta(ctx context.Context, novelID, chapterID int64, delta int)
- type WritingLog
- type WritingStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DailyActivity ¶
type DailyActivity struct {
Date string `json:"date"` // "2006-01-02"
WordsNet int `json:"words_net"` // 当天 SUM(word_delta)
WordsAdded int `json:"words_added"`
WordsDeleted int `json:"words_deleted"`
}
DailyActivity 单天汇总字数。 同时返回新增、删除和可为负数的净增。
type Store ¶
Store 管理 writing_log 持久化。
func (*Store) GetDailyActivity ¶
GetDailyActivity 返回最近 months 个月的每日字数汇总。
func (*Store) GetWritingStats ¶
func (s *Store) GetWritingStats(ctx context.Context, novelCount, chapterCount int64) (*WritingStats, error)
GetWritingStats 返回全局写作统计。
func (*Store) LogChanges ¶ added in v1.6.1
LogChanges 记录成功保存的增删量;等长替换也保留,统计失败只告警。
type WritingLog ¶
type WritingLog struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
Date string `gorm:"column:date;not null;uniqueIndex:uk_writing_date_novel;size:10"` // "2006-01-02"
NovelID int64 `gorm:"column:novel_id;not null;default:0;uniqueIndex:uk_writing_date_novel;index"`
WordDelta int `gorm:"column:word_delta;not null"`
WordsAdded int `gorm:"column:words_added;not null;default:0"`
WordsDeleted int `gorm:"column:words_deleted;not null;default:0"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}
WritingLog 按本地日期和小说累计保存版本间的增删量,WordDelta 为当天净增。
func (WritingLog) TableName ¶
func (WritingLog) TableName() string
type WritingStats ¶
type WritingStats struct {
TotalWords int `json:"total_words"`
TotalDaysActive int `json:"total_days_active"`
CurrentStreak int `json:"current_streak"`
LongestStreak int `json:"longest_streak"`
TotalNovels int64 `json:"total_novels"`
TotalChapters int64 `json:"total_chapters"`
}
WritingStats 全局写作统计。
Click to show internal directories.
Click to hide internal directories.