serverstats

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 23 Imported by: 0

README

Server stats plugin for YAGPDB

Records and shows stats for individual servers.

Current stats

Simple temporary stats:

  • Messages last hour
  • Users joined/left today
  • Messages today, per channel with bar graphs
  • Current online users
  • Total amount of users
Planned soon

More peristent graphable stats:

  • Users joined/left day to day chart
  • Avg. users online day to day
  • Messages day to day per channel
Redis layout

To count 24h stats yagpdb stores things inside sorted sets with unix timestamp as score, it will then routinely walk over all stats and remove those with screos of less then current unix time - 24h, this might be expensive later on, if so i might have to figure out a better way.

guild_stats_msg_channel:{guildid} - sorted set: key: channelid:msg_id, score: unix timestamp guild_stats_members_changed:{guildid} - sorted set: key: joined|left:userid, score: unix timestamp

Documentation

Index

Constants

View Source
const DBSchema = `` /* 376-byte string literal not displayed */

Variables

View Source
var (
	ServerStatsPeriodStore *models.StatsPeriodStore
)

Functions

func GetChannelMessageStats

func GetChannelMessageStats(raw []string, guildID int64) (map[string]*ChannelStats, error)

func HandleGuildCreate

func HandleGuildCreate(evt *eventsystem.EventData)

func HandleMemberAdd

func HandleMemberAdd(evt *eventsystem.EventData)

func HandleMemberRemove

func HandleMemberRemove(evt *eventsystem.EventData)

func HandleMessageCreate

func HandleMessageCreate(evt *eventsystem.EventData)

func HandleSaveStatsSettings added in v1.4.1

func HandleSaveStatsSettings(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleStatsHtml

func HandleStatsHtml(w http.ResponseWriter, r *http.Request, isPublicAccess bool) (web.TemplateData, error)

Somewhat dirty - should clean up this mess sometime

func HandleStatsJson

func HandleStatsJson(w http.ResponseWriter, r *http.Request, isPublicAccess bool) interface{}

func MarkGuildAsToBeChecked

func MarkGuildAsToBeChecked(guildID int64)

func ProcessTempStats

func ProcessTempStats(full bool)

ProcessTempStats moves stats from redis to postgres batched up

func RegisterPlugin

func RegisterPlugin()

func UpdateGuildStats

func UpdateGuildStats(guildID int64) error

Updates the stats on a specific guild, removing expired stats

func UpdateOldStats

func UpdateOldStats()

func UpdateStatsLoop

func UpdateStatsLoop()

Types

type ChannelStats

type ChannelStats struct {
	Name  string `json:"name"`
	Count int64  `json:"count"`
}

type FormData

type FormData struct {
	Public         bool
	IgnoreChannels []string `valid:"channel,false"`
}

type FullStats

type FullStats struct {
	ChannelsHour map[string]*ChannelStats `json:"channels_hour"`
	JoinedDay    int                      `json:"joined_day"`
	LeftDay      int                      `json:"left_day"`
	Online       int                      `json:"online_now"`
	TotalMembers int                      `json:"total_members_now"`
}

func RetrieveFullStats

func RetrieveFullStats(guildID int64) (*FullStats, error)

func RetrieveRedisStats

func RetrieveRedisStats(guildID int64) (*FullStats, error)

type Plugin

type Plugin struct{}

func (*Plugin) AddCommands added in v1.4.1

func (p *Plugin) AddCommands()

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) StopBot added in v1.4.1

func (p *Plugin) StopBot(wg *sync.WaitGroup)

type ServerStatsConfig

type ServerStatsConfig struct {
	configstore.GuildConfigModel
	Public         bool
	IgnoreChannels string

	ParsedChannels []int64 `gorm:"-"`
}

func GetConfig

func GetConfig(ctx context.Context, GuildID int64) (*ServerStatsConfig, error)

func (*ServerStatsConfig) GetName

func (c *ServerStatsConfig) GetName() string

func (*ServerStatsConfig) PostFetch

func (s *ServerStatsConfig) PostFetch()

Directories

Path Synopsis
IMPORTANT! This is auto generated code by https://github.com/src-d/go-kallax Please, do not touch the code below, and if you do, do it under your own risk.
IMPORTANT! This is auto generated code by https://github.com/src-d/go-kallax Please, do not touch the code below, and if you do, do it under your own risk.

Jump to

Keyboard shortcuts

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