diff --git a/backend/backend.go b/backend/backend.go index 2c700bd..78390bb 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -26,6 +26,7 @@ type Backend interface { // Entries GetEntries() ([]noko.Entry, error) + GetMyEntries() ([]noko.Entry, error) // Output Write(p []byte) (n int, err error) diff --git a/backend/mock.go b/backend/mock.go index e794951..06182e5 100644 --- a/backend/mock.go +++ b/backend/mock.go @@ -9,10 +9,11 @@ import ( var ErrNotImplemented = errors.New("not implemented") type MockBackend struct { - Projects []noko.Project - Timers []noko.Timer - Entries []noko.Entry - Output *bytes.Buffer + Projects []noko.Project + Timers []noko.Timer + Entries []noko.Entry + MyEntries []noko.Entry + Output *bytes.Buffer } func (m *MockBackend) Init() error { @@ -83,3 +84,7 @@ func (m *MockBackend) GetSomeProjects(withTimer bool) ([]noko.Project, error) { func (m *MockBackend) GetEntries() ([]noko.Entry, error) { return m.Entries, nil } + +func (m *MockBackend) GetMyEntries() ([]noko.Entry, error) { + return m.MyEntries, nil +} diff --git a/backend/real.go b/backend/real.go index 4d48064..5ac2ec8 100644 --- a/backend/real.go +++ b/backend/real.go @@ -167,10 +167,18 @@ func (m *RealBackend) GetSomeProjects(withTimer bool) ([]noko.Project, error) { } func (m *RealBackend) GetEntries() ([]noko.Entry, error) { + return m.getEntries(false) +} + +func (m *RealBackend) GetMyEntries() ([]noko.Entry, error) { + return m.getEntries(true) +} + +func (m *RealBackend) getEntries(currentUser bool) ([]noko.Entry, error) { client := noko.NewClient() ctx, cancel := standardContext() defer cancel() - return client.GetEntries(ctx, false) + return client.GetEntries(ctx, currentUser) } func standardContext() (context.Context, context.CancelFunc) {