report

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartMarker = "<!-- discrawl-report:start -->"
	EndMarker   = "<!-- discrawl-report:end -->"
)

Variables

This section is empty.

Functions

func MarkdownTable

func MarkdownTable(rows []RankedCount, nameTitle string) string

func RenderMarkdown

func RenderMarkdown(report ActivityReport) (string, error)

func UpdateReadme

func UpdateReadme(readme []byte, section string) []byte

func WriteReadme

func WriteReadme(path string, section string) error

Types

type ActivityReport

type ActivityReport struct {
	GeneratedAt     time.Time
	LatestMessageAt time.Time
	TotalMessages   int
	TotalChannels   int
	TotalMembers    int
	Windows         []WindowStats
	TopChannels     []RankedCount
	TopAuthors      []RankedCount
	BusiestDays     []RankedCount
}

func Build

func Build(ctx context.Context, s *store.Store, opts Options) (ActivityReport, error)

type ChannelDigest

type ChannelDigest struct {
	ChannelID     string        `json:"channel_id"`
	ChannelName   string        `json:"channel_name"`
	Kind          string        `json:"kind,omitempty"`
	GuildID       string        `json:"guild_id"`
	Messages      int           `json:"messages"`
	Replies       int           `json:"replies"`
	ActiveAuthors int           `json:"active_authors"`
	TopPosters    []RankedCount `json:"top_posters"`
	TopMentions   []RankedCount `json:"top_mentions"`
}

ChannelDigest is the per-channel roll-up inside a Digest.

type Digest

type Digest struct {
	GeneratedAt time.Time       `json:"generated_at"`
	Since       time.Time       `json:"since"`
	Until       time.Time       `json:"until"`
	WindowLabel string          `json:"window_label"`
	Guild       string          `json:"guild,omitempty"`
	Channel     string          `json:"channel,omitempty"`
	TopN        int             `json:"top_n"`
	Channels    []ChannelDigest `json:"channels"`
	Totals      DigestTotals    `json:"totals"`
}

Digest summarizes recent activity for each channel inside a window.

func BuildDigest

func BuildDigest(ctx context.Context, s *store.Store, opts DigestOptions) (Digest, error)

BuildDigest computes a per-channel activity digest from the local store.

type DigestOptions

type DigestOptions struct {
	Now     time.Time
	Since   time.Duration
	GuildID string
	Channel string
	TopN    int
}

DigestOptions controls how a Digest is built.

type DigestTotals

type DigestTotals struct {
	Messages      int `json:"messages"`
	Replies       int `json:"replies"`
	Channels      int `json:"channels"`
	ActiveAuthors int `json:"active_authors"`
}

DigestTotals sums message and channel counts across the digest window.

type Options

type Options struct {
	Now time.Time
}

type Quiet

type Quiet struct {
	GeneratedAt time.Time      `json:"generated_at"`
	Since       time.Time      `json:"since"`
	Until       time.Time      `json:"until"`
	Guild       string         `json:"guild,omitempty"`
	Channels    []QuietChannel `json:"channels"`
	Totals      QuietTotals    `json:"totals"`
}

Quiet summarizes channels with no activity in a window.

func BuildQuiet

func BuildQuiet(ctx context.Context, s *store.Store, opts QuietOptions) (Quiet, error)

BuildQuiet computes channels with no messages newer than the lookback window.

type QuietChannel

type QuietChannel struct {
	ChannelID   string `json:"channel_id"`
	ChannelName string `json:"channel_name"`
	Kind        string `json:"kind,omitempty"`
	GuildID     string `json:"guild_id"`
	LastMessage string `json:"last_message,omitempty"`
	DaysSilent  int    `json:"days_silent"`
}

QuietChannel is one channel with no recent activity.

type QuietOptions

type QuietOptions struct {
	Now     time.Time
	Since   time.Duration
	GuildID string
}

QuietOptions controls how a Quiet report is built.

type QuietTotals

type QuietTotals struct {
	Channels int `json:"channels"`
}

QuietTotals summarizes quiet-channel counts.

type RankedCount

type RankedCount struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}
type Trends struct {
	GeneratedAt time.Time   `json:"generated_at"`
	Since       time.Time   `json:"since"`
	Until       time.Time   `json:"until"`
	Weeks       int         `json:"weeks"`
	Guild       string      `json:"guild,omitempty"`
	Channel     string      `json:"channel,omitempty"`
	Rows        []TrendsRow `json:"rows"`
}

Trends summarizes week-over-week message volume per channel.

func BuildTrends

func BuildTrends(ctx context.Context, s *store.Store, opts TrendsOptions) (Trends, error)

BuildTrends computes Monday-start UTC weekly message counts per channel.

type TrendsOptions

type TrendsOptions struct {
	Now     time.Time
	Weeks   int
	GuildID string
	Channel string
}

TrendsOptions controls how a Trends report is built.

type TrendsRow

type TrendsRow struct {
	GuildID     string        `json:"guild_id"`
	ChannelID   string        `json:"channel_id"`
	ChannelName string        `json:"channel_name"`
	Kind        string        `json:"kind,omitempty"`
	Weekly      []WeeklyCount `json:"weekly"`
}

TrendsRow is one channel's weekly message trend.

type WeeklyCount

type WeeklyCount struct {
	WeekStart time.Time `json:"week_start"`
	Messages  int       `json:"messages"`
}

WeeklyCount is the message count for one Monday-start UTC week.

type WindowStats

type WindowStats struct {
	Label          string
	Since          time.Time
	Messages       int
	ActiveAuthors  int
	ActiveChannels int
	Attachments    int
}

Jump to

Keyboard shortcuts

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