Documentation
¶
Index ¶
- type IdleDetector
- type ProjectDetector
- type Session
- type SessionState
- type Tracker
- func (t *Tracker) Close() error
- func (t *Tracker) GetCurrentSession() (*Session, error)
- func (t *Tracker) GetDailyTotal() (time.Duration, error)
- func (t *Tracker) GetIdleTime() (time.Duration, error)
- func (t *Tracker) GetProjectStats() (map[string]time.Duration, error)
- func (t *Tracker) GetSessionDuration() (time.Duration, error)
- func (t *Tracker) GetSessionHistory(limit int) ([]*Session, error)
- func (t *Tracker) GetWeeklyTotal() (time.Duration, error)
- func (t *Tracker) IsIdle() (bool, error)
- func (t *Tracker) Pause() (*Session, error)
- func (t *Tracker) Resume() (*Session, error)
- func (t *Tracker) SaveImportedSession(session *Session) error
- func (t *Tracker) SetIdleThreshold(threshold time.Duration)
- func (t *Tracker) Start(project string) (*Session, error)
- func (t *Tracker) StartIdleMonitoring() error
- func (t *Tracker) Stop() (*Session, error)
- func (t *Tracker) StopIdleMonitoring()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IdleDetector ¶
type IdleDetector struct {
// contains filtered or unexported fields
}
IdleDetector handles idle time detection across platforms
func NewIdleDetector ¶
func NewIdleDetector(threshold time.Duration) *IdleDetector
NewIdleDetector creates a new idle detector with the given threshold
func (*IdleDetector) GetIdleTime ¶
func (id *IdleDetector) GetIdleTime() (time.Duration, error)
GetIdleTime returns the current system idle time
func (*IdleDetector) IsIdle ¶
func (id *IdleDetector) IsIdle() (bool, error)
IsIdle returns true if the system has been idle longer than the threshold
func (*IdleDetector) StartIdleMonitoring ¶
func (id *IdleDetector) StartIdleMonitoring(onIdleStart, onIdleEnd func()) chan struct{}
StartIdleMonitoring starts monitoring for idle state changes
type ProjectDetector ¶
type ProjectDetector struct{}
ProjectDetector handles automatic project detection
func NewProjectDetector ¶
func NewProjectDetector() *ProjectDetector
NewProjectDetector creates a new project detector
func (*ProjectDetector) DetectProject ¶
func (pd *ProjectDetector) DetectProject() string
DetectProject attempts to detect the current project based on working directory
func (*ProjectDetector) SanitizeProjectName ¶
func (pd *ProjectDetector) SanitizeProjectName(name string) string
SanitizeProjectName cleans up project names
type Session ¶
type Session struct {
ID string `json:"id"`
Project string `json:"project"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
PausedAt *time.Time `json:"paused_at,omitempty"`
Duration time.Duration `json:"duration"`
State SessionState `json:"state"`
}
Session represents a work session
type SessionState ¶
type SessionState int
SessionState represents the current state of a work session
const ( StateStopped SessionState = iota StateRunning StatePaused )
func (SessionState) String ¶
func (s SessionState) String() string
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker manages time tracking sessions
func NewTrackerWithIdleThreshold ¶
NewTrackerWithIdleThreshold creates a new time tracker with custom idle threshold
func (*Tracker) GetCurrentSession ¶
GetCurrentSession returns the current active session
func (*Tracker) GetDailyTotal ¶
GetDailyTotal returns the total time worked today
func (*Tracker) GetIdleTime ¶
GetIdleTime returns the current system idle time
func (*Tracker) GetProjectStats ¶
GetProjectStats returns time statistics by project
func (*Tracker) GetSessionDuration ¶
GetSessionDuration returns the current session duration
func (*Tracker) GetSessionHistory ¶
GetSessionHistory returns recent sessions
func (*Tracker) GetWeeklyTotal ¶
GetWeeklyTotal returns the total time worked this week
func (*Tracker) SaveImportedSession ¶
SaveImportedSession saves an imported session to the database
func (*Tracker) SetIdleThreshold ¶
SetIdleThreshold sets the idle detection threshold
func (*Tracker) StartIdleMonitoring ¶
StartIdleMonitoring starts monitoring for idle state changes
func (*Tracker) StopIdleMonitoring ¶
func (t *Tracker) StopIdleMonitoring()
StopIdleMonitoring stops idle monitoring