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

writing

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 5 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"
	WordsNet     int    `json:"words_net"` // 当天 SUM(word_delta)
	WordsAdded   int    `json:"words_added"`
	WordsDeleted int    `json:"words_deleted"`
}

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) LogChanges added in v1.6.1

func (s *Store) LogChanges(ctx context.Context, novelID, chapterID int64, added, deleted int)

LogChanges 记录成功保存的增删量;等长替换也保留,统计失败只告警。

func (*Store) LogDelta

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

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

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

Jump to

Keyboard shortcuts

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