Documentation
¶
Index ¶
- func Filename(index int) string
- func Index(filename string) int
- func NewLogger() *log.Logger
- func TruncateDay(timestamp int64) int64
- func TruncateMonth(timestamp int64) int64
- func TruncateWeek(timestamp int64) int64
- func TruncateYear(timestamp int64) int64
- type Buffer
- type Buffers
- type CodingSession
- type CodingSessions
- type Config
- type Event
- type File
- type Files
- type GitFile
- type HashIndex
- type LogDB
- func (db *LogDB) Aggregate() map[string][]byte
- func (db *LogDB) Get(key string) ([]byte, bool)
- func (db *LogDB) GetAllUnique() map[string][]byte
- func (db *LogDB) MustSet(key string, value []byte)
- func (db *LogDB) RunSegmentations(ctx context.Context, segmentationInterval time.Duration)
- func (db *LogDB) Set(key string, value []byte) error
- type Period
- type Record
- type RecordWithOffset
- type Repositories
- type Repository
- type Segment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
New wraps the construction of a charmbracelet logger in order to achieve coherent styles and settings.
func TruncateDay ¶
TruncateDay truncates the timestamp to the start of the day.
func TruncateMonth ¶
TruncateMonth truncates the timestamp to the start of the month.
func TruncateWeek ¶
TruncateWeek truncates the timestamp to the start of the week.
func TruncateYear ¶
TruncateYear truncates the timestamp to the start of the year.
Types ¶
type Buffer ¶
type Buffer struct {
OpenedAt time.Time `json:"-"`
ClosedAt time.Time `json:"-"`
Duration time.Duration `json:"duration"`
Filename string `json:"filename"`
Filepath string `json:"filepath"`
Filetype string `json:"filetype"`
Repository string `json:"repository"`
}
Buffer rerpresents a buffer that has been edited during a coding session.
type Buffers ¶
type Buffers []Buffer
Buffers represents a slice of buffers that have been edited during a coding session.
type CodingSession ¶
type CodingSession struct {
ID string `bson:"_id,omitempty"`
Period Period `bson:"period"`
EpochDateMs int64 `bson:"date"`
DateString string `bson:"date_string"`
TotalTimeMs int64 `bson:"total_time_ms"`
Repositories Repositories `bson:"repositories"`
}
CodingSession represents a coding session that has been aggregated for a given time period (day, week, month, year).
func NewCodingSession ¶
func NewCodingSession(buffers Buffers, now time.Time) CodingSession
type CodingSessions ¶
type CodingSessions []CodingSession
CodingSessions represents a slice of coding sessions.
func (CodingSessions) MergeByDay ¶
func (s CodingSessions) MergeByDay() CodingSessions
MergeByDay merges sessions that occurred the same day.
func (CodingSessions) MergeByMonth ¶
func (s CodingSessions) MergeByMonth() CodingSessions
MergeByWeek merges sessions that occurred the same month.
func (CodingSessions) MergeByWeek ¶
func (s CodingSessions) MergeByWeek() CodingSessions
MergeByWeek merges sessions that occurred the same week.
func (CodingSessions) MergeByYear ¶
func (s CodingSessions) MergeByYear() CodingSessions
MergeByYear merges sessions that occurred the same year.
type Config ¶
type Config struct {
Server struct {
Name string
Hostname string
Port string
AggregationInterval time.Duration
SegmentationInterval time.Duration
SegmentSizeKB int
}
Database struct {
Name string
URI string
Collection string
}
}
func ParseConfig ¶
type File ¶
type File struct {
Name string `bson:"name"`
Path string `bson:"path"`
Filetype string `bson:"filetype"`
DurationMs int64 `bson:"duration_ms"`
}
File represents a file that has been aggregated for a given time period (day, week, month, year).
type Files ¶
type Files []File
Files represents a slice of files that has been aggregated for a given time period (day, week, month, year).
type LogDB ¶
LogDB is a simple key-value store that persists data to a log file.
func (*LogDB) Aggregate ¶
Aggregate gathers all the unique key-value pairs in the database, and then removes all the segments and resets the state.
func (*LogDB) GetAllUnique ¶
func (*LogDB) RunSegmentations ¶
RunSegmentations starts the database's compaction process.
type Period ¶
type Period int8
Period represents the time period for which the coding sessions have been aggregated.
type RecordWithOffset ¶
RecordWithOffset holds a record and its offset in the log file.
type Repositories ¶
type Repositories []Repository
Repositories represents a list of git repositories.
type Repository ¶
type Repository struct {
Name string `bson:"name"`
Files Files `bson:"files"`
DurationMs int64 `bson:"duration_ms"`
}
Repository represents a git repository. A coding session might open files across any number of repos. The files of the coding session are later grouped by repository.

