services

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const BucketAccount = "account"
View Source
const GoalsBucket = "goals"
View Source
const MaxNumPerRequest = int64(1000)
View Source
const SettingBucket = "settings"

Variables

View Source
var ContextBucket = "contexts"
View Source
var DefaultFieldsInResponse = "folder,star,context,tag,goal,repeat,startdate,starttime,duedate,duetime,priority,length"
View Source
var FolderBucket = "folders"
View Source
var TaskBucket = "tasks"

Functions

func CurrentUser

func CurrentUser(svc AccountExtService) (*models.Account, error)

CurrentUser return live user TODO move to cli

func FindContextByName

func FindContextByName(auth runtime.ClientAuthInfoWriter, name string) (*models.Context, error)

TODO using wire

func SortSubTasks

func SortSubTasks(tasks []*models.Task, mode subtasksview.Mode) ([]*models.Task, error)

Types

type AccountExtService

type AccountExtService interface {
	Me() (*models.Account, error)
	CachedMe() (*models.Account, bool, error)
	// GetLastFetchInfo return last fetch info in db
	// lastFetchInfo maybe nil if never sync
	FindLastFetchInfo() (*models.Account, error)
	ModifyLastFetchInfo(account *models.Account) error
}

func NewAccountExtService

func NewAccountExtService(
	cli *client0.Toodledo,
	auth runtime.ClientAuthInfoWriter,
	db dal.Backend,
	accountSvc AccountService,
) AccountExtService

type AccountService

type AccountService interface {
	Me() (*models.Account, error)
}

type ContextPersistenceService

type ContextPersistenceService interface {
	Synchronizable
	ContextService
}

ContextPersistenceService is a cached service it synced interval by fetcher.

func NewContextCachedService

func NewContextCachedService(contextsvc ContextService, accountSvc AccountExtService,
	db dal.Backend) ContextPersistenceService

func ProvideContextCachedService

func ProvideContextCachedService(svc ContextService, accountSvc AccountExtService,
	db dal.Backend) ContextPersistenceService

type ContextService

type ContextService interface {
	Find(name string) (*models.Context, error)
	FindByID(id int64) (*models.Context, error)
	ListAll() ([]*models.Context, error)
	Rename(name string, newName string) (*models.Context, error)
	Delete(name string) error
	Create(name string) (*models.Context, error)
}

type FolderPersistenceService

type FolderPersistenceService interface {
	Synchronizable
	FolderService
}

FolderPersistenceService is a cached service it synced interval by fetcher.

func NewFolderCachedService

func NewFolderCachedService(folderSvc FolderService, accountSvc AccountExtService,
	db dal.Backend) FolderPersistenceService

func ProvideFolderCachedService

func ProvideFolderCachedService(
	svc FolderService,
	accountSvc AccountExtService,
	db dal.Backend,
) FolderPersistenceService

type FolderService

type FolderService interface {
	Find(name string) (*models.Folder, error)
	FindByID(id int64) (*models.Folder, error)
	ListAll() ([]*models.Folder, error)
	Rename(name string, newName string) (*models.Folder, error)
	Archive(id int, isArchived bool) (*models.Folder, error)
	Delete(name string) error
	Create(name string) (*models.Folder, error)
}

type GoalPersistenceService

type GoalPersistenceService interface {
	Synchronizable
	GoalService
}

GoalPersistenceService is a cached service it synced interval by fetcher.

func NewGoalCachedService

func NewGoalCachedService(goalSvc GoalService, accountSvc AccountExtService, db dal.Backend) GoalPersistenceService

type GoalService

type GoalService interface {
	Find(name string) (*models.Goal, error)
	FindByID(id int64) (*models.Goal, error)
	Archive(id int, isArchived bool) (*models.Goal, error)
	Delete(name string) error
	Rename(name string, newName string) (*models.Goal, error)
	Create(name string) (*models.Goal, error)
	// ListAll returns all goals except archived
	ListAll() ([]*models.Goal, error)
	ListAllWithArchived() ([]*models.Goal, error)
}

type SavedSearchService

type SavedSearchService interface {
	ListAll() ([]*models.SavedSearch, error)
}

type SettingService

type SettingService interface {
	Find(name string) (string, error)
	Put(name, body string) error
	Delete(name string) error
}

func NewSettingService

func NewSettingService(log logrus.FieldLogger, db dal.Backend) SettingService

type Synchronizable

type Synchronizable interface {
	Clean() error
	Sync() error
	// PartialSync sync data after lastEditTime
	PartialSync(lastEditTime *int32) error
}

Synchronizable represents stores data in local, and impl the sync methods.

type TaskExtendedService

type TaskExtendedService interface {
	TaskService

	// ListAllByQuery is list tasks by query, in-completed default, and with today complted tasks
	ListAllByQuery(query *queries.TaskListQuery) ([]*models.Task, error)
}

TaskExtendedService is a service for tasks, it provided more query parameters.

func ProvideTaskLocalExtServiceIft

func ProvideTaskLocalExtServiceIft(
	taskSvc TaskService,
	accountSvc AccountExtService,
	db dal.Backend,
) TaskExtendedService

type TaskPersistenceExtService

type TaskPersistenceExtService interface {
	TaskService
	TaskExtendedService
	Synchronizable
}

func NewTaskLocalExtService

func NewTaskLocalExtService(
	taskSvc TaskService,
	accountSvc AccountExtService,
	db dal.Backend,
) TaskPersistenceExtService

func ProvideTaskLocalExtService

func ProvideTaskLocalExtService(taskSvc TaskService, accountSvc AccountExtService,
	db dal.Backend) TaskPersistenceExtService

type TaskRichCachedService

type TaskRichCachedService = TaskRichService

func NewTaskRichPersistenceService

func NewTaskRichPersistenceService(
	taskSvc TaskPersistenceExtService,
	folderSvc FolderPersistenceService,
	contextSvc ContextPersistenceService,
	goalSvc GoalPersistenceService,
	logger logrus.FieldLogger,
) TaskRichCachedService

NewTaskRichPersistenceService returns a new TaskRichCachedService. svc inside will cache the attribute when rich the task.

type TaskRichService

type TaskRichService interface {
	Find(id int64) (*models.RichTask, error)
	Rich(tasks *models.Task) (*models.RichTask, error)
	RichThem(tasks []*models.Task) ([]*models.RichTask, error)
}

func NewTaskRichService

func NewTaskRichService(
	taskSvc TaskService,
	folderSvc FolderService,
	contextSvc ContextService,
	goalSvc GoalPersistenceService,
	logger logrus.FieldLogger,
) TaskRichService

NewTaskRichService returns a new TaskRichService. it will not cache the attribute when rich the task, and query the attribute from remote Please use the NewTaskRichPersistenceService first.

type TaskService

type TaskService interface {
	FindByID(id int64) (*models.Task, error)
	List(start, limit int64) ([]*models.Task, *models.PaginatedInfo, error)
	ListAll() ([]*models.Task, int, error)
	// TODO
	// ListAllAfter(after *time.Time) ([]*models.Task, error)
	// Create is simple create with only title, it was deprecated
	Create(title string) (*models.Task, error)
	CreateByQuery(query *queries.TaskCreateQuery) (*models.Task, error)
	Delete(id int64) error
	// DeleteBatch is batch delete tasks, return success ids, failed items and error
	DeleteBatch(ids []int64) ([]int64, []*models.TaskDeleteItem, error)
	Edit(id int64, t *models.TaskEdit) (*models.Task, error)
	EditByQuery(query *queries.TaskEditQuery) (*models.Task, error)
	Complete(id int64) (*models.Task, error)
	UnComplete(id int64) (*models.Task, error)
	ListDeleted(lastEditTime *int32) ([]*models.TaskDeleted, error)
	ListWithChanged(lastEditTime *int32, start, limit int64) ([]*models.Task, *models.PaginatedInfo, error)
	Start(id int64) error
	Stop(id int64) error
}

Jump to

Keyboard shortcuts

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