Documentation ¶
Index ¶
- func DaysDiff(a, b time.Time) (days int64)
- func DaysDiffUnix(unixTimeA int64, unixTimeB int64) (days int64)
- type Averages
- type Channel
- type Config
- type Database
- func (d *Database) AddUser(u User)
- func (d Database) CheckVersion(version string) (ok bool, err error)
- func (d Database) CountUsers() int64
- func (d Database) GetUser(nick string) (user User, err error)
- func (d Database) HasUser(nick string) bool
- func (d *Database) Load(path string) (err error)
- func (d Database) Save(path string) (err error)
- func (d *Database) SetUser(nick string, u User)
- type HoursAndDaysStats
- func (s HoursAndDaysStats) FindDayAverage() (avg float64)
- func (s HoursAndDaysStats) FindHourAverage() (avg float64)
- func (s HoursAndDaysStats) FindPeakDay() (date string, total int64)
- func (s HoursAndDaysStats) FindPeakHour() (hour int64, total int64)
- func (s HoursAndDaysStats) FindPeakWeek() (week int64, total int64)
- func (s HoursAndDaysStats) FindPeakWeekDay() (weekday int64, total int64)
- func (s HoursAndDaysStats) FindWeekAverage() (avg float64)
- func (s HoursAndDaysStats) FindWeekDayAverage() (avg float64)
- func (s HoursAndDaysStats) HasDay(day string) bool
- func (s *HoursAndDaysStats) IncrementDay(date string, increment int64)
- func (s *HoursAndDaysStats) IncrementHour(hour uint)
- func (s *HoursAndDaysStats) IncrementWeek(week int, increment int64)
- func (s *HoursAndDaysStats) Initiate()
- type IrcLogReader
- type JsonData
- type MaxDay
- type MaxHour
- type MaxWeek
- type MaxWeekDay
- type Seen
- type SvgGraphDay
- type TimeZone
- type User
- type UserData
- type View
- type ViewData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DaysDiffUnix ¶
Days diff for unix time a - b in days
Types ¶
type Channel ¶
type Channel struct { Name string // Channel Name ActiveUsers map[string]User // Active users in past 30 days UserCount int64 // Total Number of users in Channel LineCount int64 // Total Number of lines in Channel WordCount int64 // Total Word count for Channel MaxDay MaxDay // Calculated Max Day MaxHour MaxHour // Calculated Max Hour MaxWeek MaxWeek // Calculated Max Week Averages Averages // Calculated Averages HoursAndDaysStats // Inherited Hour And Days methods Seen // First & Last Seen }
Channel Statistics
type Config ¶
type Database ¶
type Database struct { Users map[string]User // Users LastGenerated int64 // Unix timestamp of last generated Version string // Version of application that this works with, if the version changes we need to check for incompatibility Channel Channel // Channel counters for storage }
Cached data that has been parsed is stored in the Database struct. Once execution is complete is can save to disk this saves us from restarting from the beginning of the file.
The primary data that is stored here is parsed user stats
func (Database) CheckVersion ¶
At some point this needs to check the version @todo implement this
func (Database) CountUsers ¶
Return count of Users in data store
type HoursAndDaysStats ¶
type HoursAndDaysStats struct { Weeks [54]int64 // lines per 52 weeks Hours [24]int64 // lines per 24 hours @todo check that all 24 elements are being filled... Days map[string]int64 // words per day }
func (HoursAndDaysStats) FindDayAverage ¶
func (s HoursAndDaysStats) FindDayAverage() (avg float64)
func (HoursAndDaysStats) FindHourAverage ¶
func (s HoursAndDaysStats) FindHourAverage() (avg float64)
func (HoursAndDaysStats) FindPeakDay ¶
func (s HoursAndDaysStats) FindPeakDay() (date string, total int64)
func (HoursAndDaysStats) FindPeakHour ¶
func (s HoursAndDaysStats) FindPeakHour() (hour int64, total int64)
func (HoursAndDaysStats) FindPeakWeek ¶
func (s HoursAndDaysStats) FindPeakWeek() (week int64, total int64)
func (HoursAndDaysStats) FindPeakWeekDay ¶
func (s HoursAndDaysStats) FindPeakWeekDay() (weekday int64, total int64)
func (HoursAndDaysStats) FindWeekAverage ¶
func (s HoursAndDaysStats) FindWeekAverage() (avg float64)
func (HoursAndDaysStats) FindWeekDayAverage ¶
func (s HoursAndDaysStats) FindWeekDayAverage() (avg float64)
func (HoursAndDaysStats) HasDay ¶
func (s HoursAndDaysStats) HasDay(day string) bool
func (*HoursAndDaysStats) IncrementDay ¶
func (s *HoursAndDaysStats) IncrementDay(date string, increment int64)
Increment Days by an input number
func (*HoursAndDaysStats) IncrementHour ¶
func (s *HoursAndDaysStats) IncrementHour(hour uint)
Increment Hours by one
func (*HoursAndDaysStats) IncrementWeek ¶
func (s *HoursAndDaysStats) IncrementWeek(week int, increment int64)
Increment Weeks by an input number
func (*HoursAndDaysStats) Initiate ¶
func (s *HoursAndDaysStats) Initiate()
type IrcLogReader ¶
type IrcLogReader struct { RegexAction *regexp.Regexp RegexMessage *regexp.Regexp RegexParseAction *regexp.Regexp RegexParseMessage *regexp.Regexp NickNameHashTable map[string]string // Nickname hash table from configuration Profiles map[string]map[string]string // Profile hash table from configuration Ignore []string // Ignore list from configuration // contains filtered or unexported fields }
This IRC Log Reader parses through each line of the input file and pushes it to Database
func NewIrcLogReader ¶
func NewIrcLogReader(c Config) *IrcLogReader
func (IrcLogReader) IsUserIgnored ¶
func (lr IrcLogReader) IsUserIgnored(username string) bool
Identify if the user is to be ignored
func (IrcLogReader) MapNick ¶
func (lr IrcLogReader) MapNick(username string) string
Map the users nick if found in the configuration against a mapping.
func (IrcLogReader) NewLinesFound ¶
func (lr IrcLogReader) NewLinesFound() int64
type JsonData ¶
type JsonData struct { // Configurable options HeatMapInterval uint // HeatMap Interval from configuration ActivityPeriod uint // Activity Period from configuration // Dates GeneratedAt int64 // Timestamp of last generated at FirstSeen int64 // Timestamp of first message LastSeen int64 // Timestamp of last message TotalDaysSeen int64 // Number of days between FirstSeen and LastSeen TimeZone TimeZone // Averages Averages Averages // Calculated Averages // Counters MaxDay MaxDay // Calculated Max Day MaxWeekDay MaxWeekDay // Calculated Max Week Day MaxHour MaxHour // Calculated Max Hour MaxWeek MaxWeek // Calculated Max Week TotalLines int64 // Lines parsed in total TotalWords int64 // Total Words (all words multiplied by times used) TotalUsers int64 // Number of unique users TotalActiveUsers int64 // Number of active users within activity period (default 30 days) // Graph Data Days []SvgGraphDay Hours [24]int64 // Misc Users map[string]UserData // Users list SortedActiveUsers []string // Sorted Users map by "activity" SortedTopUsers []string // Sorted Users map by words }
type MaxWeekDay ¶
type SvgGraphDay ¶
Data mapping for passing day date data to front end JSON This is used for the heatmap
type User ¶
type User struct { Username string Url string Avatar string LineCount int64 WordCount int64 // * DaysActive int64 // * CharCount int64 // * //WordsLine int64 LineLength int64 LinesDay int64 WordsDay int64 Vocabulary int64 //DaysTotal int64 //MaxHours int64 Words map[string]int64 // A Map of words and usage HoursAndDaysStats Seen }
type UserData ¶
type UserData struct { Username string Url string Avatar string FirstSpoke int64 LastSpoke int64 TotalWords int64 // Count of words Averages Averages // Used for words/day Vocabulary int64 // Number of different words used DaysActiveInPeriod int64 TotalWordsInPeriod int64 WordsByDayInPeriod float64 ActivityPercentage float64 // Overall % contribution to Channel.WordCount }
Data mapping for front end JSON
type ViewData ¶
type ViewData struct { PageTitle string // Page title from configuration PageDescription string // Page description from configuration JsonData JsonData // Json data for exporting to page }
This view data struct will contain all the data that will be injected into the view template. Ideally this will be done as a JSON export so that JavaScript within the view can transform it in any way it sees fit.
func NewViewData ¶
func (ViewData) GetJsonString ¶
Returns a json string of the JsonData, good for debugging.