Help us shape the future of Go! Take the 2026 Go Developer Survey

writing

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

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"
	Words int    `json:"words"` // 当天 SUM(word_delta)
}

DailyActivity 单天汇总字数。

type Store

type Store struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

Store 管理 writing_log 持久化。

func NewStore

func NewStore(db *gorm.DB, logger *slog.Logger) *Store

NewStore 创建写作日志存储。

func (*Store) GetDailyActivity

func (s *Store) GetDailyActivity(ctx context.Context, months int) ([]DailyActivity, error)

GetDailyActivity 返回最近 months 个月的每日字数汇总。

func (*Store) GetWritingStats

func (s *Store) GetWritingStats(ctx context.Context, novelCount, chapterCount int64) (*WritingStats, error)

GetWritingStats 返回全局写作统计。

func (*Store) LogDelta

func (s *Store) LogDelta(ctx context.Context, novelID int64, chapterNumber int, delta int)

LogDelta 记录一次字数变化。delta 为 0 时跳过。

type WritingLog

type WritingLog struct {
	ID            int64     `gorm:"column:id;primaryKey;autoIncrement"`
	Date          string    `gorm:"column:date;not null;index:idx_writing_date;size:10"` // "2006-01-02"
	NovelID       int64     `gorm:"column:novel_id;not null;default:0;index"`
	ChapterNumber int       `gorm:"column:chapter_number;not null;default:0;index"`
	WordDelta     int       `gorm:"column:word_delta;not null"`
	CreatedAt     time.Time `gorm:"column:created_at;autoCreateTime"`
}

WritingLog 记录每次保存的字数变化。正数表示新增,负数表示删除。 多行同一天的不同保存各自独立,查询时按 date GROUP BY SUM(word_delta)。

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 全局写作统计。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL