catalogviews

package
v1.6.27 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlbumReCounter added in v1.6.7

type AlbumReCounter struct {
	ListUserWhoCanAccessAlbumPort ListUserWhoCanAccessAlbumPort
	MediaCounterPort              MediaCounterPort
}

func (*AlbumReCounter) ReCountMedias added in v1.6.7

func (c *AlbumReCounter) ReCountMedias(ctx context.Context, albumIds []catalog.AlbumId, observers ...InsertAlbumSizePort) error

type AlbumSize added in v1.6.4

type AlbumSize struct {
	AlbumId    catalog.AlbumId
	MediaCount int
}

type AlbumSizeDiff added in v1.6.4

type AlbumSizeDiff struct {
	AlbumId        catalog.AlbumId
	Users          []Availability
	MediaCountDiff int // MediaCountDiff is the difference between the number of media added, or removed, to the album
}

type AlbumSizeInMemoryRepository added in v1.6.7

type AlbumSizeInMemoryRepository struct {
	Sizes []UserAlbumSize
}

func (*AlbumSizeInMemoryRepository) DeleteAlbumSize added in v1.6.7

func (r *AlbumSizeInMemoryRepository) DeleteAlbumSize(ctx context.Context, availability Availability, albumId catalog.AlbumId) error

func (*AlbumSizeInMemoryRepository) GetAlbumSizes added in v1.6.7

func (r *AlbumSizeInMemoryRepository) GetAlbumSizes(ctx context.Context, userId usermodel.UserId, owner ...ownermodel.Owner) ([]UserAlbumSize, error)

func (*AlbumSizeInMemoryRepository) GetAvailabilitiesByUser added in v1.6.7

func (r *AlbumSizeInMemoryRepository) GetAvailabilitiesByUser(ctx context.Context, userId usermodel.UserId) ([]UserAlbumSize, error)

func (*AlbumSizeInMemoryRepository) InsertAlbumSize added in v1.6.7

func (r *AlbumSizeInMemoryRepository) InsertAlbumSize(ctx context.Context, albumSize []MultiUserAlbumSize) error

func (*AlbumSizeInMemoryRepository) UpdateAlbumSize added in v1.6.7

func (r *AlbumSizeInMemoryRepository) UpdateAlbumSize(ctx context.Context, albumCountUpdates []AlbumSizeDiff) error

type AlbumView

type AlbumView struct {
	Providers []ListAlbumsProvider
}

func NewAlbumView added in v1.5.49

func NewAlbumView(
	FindAlbumByOwnerPort FindAlbumByOwnerPort,
	GetAlbumSharingGridPort GetAlbumSharingGridPort,
	FindAlbumsByIdsPort FindAlbumsByIdsPort,
	SharedWithUserPort SharedWithUserPort,
	GetAvailabilitiesByUserPort GetAvailabilitiesByUserPort,
) *AlbumView

func (*AlbumView) ListAlbums

func (v *AlbumView) ListAlbums(ctx context.Context, user usermodel.CurrentUser, filter ListAlbumsFilter) ([]*VisibleAlbum, error)

ListAlbums returns albums visible by the user (owned by current user, and shared to him)

type Availability added in v1.6.4

type Availability struct {
	UserId  usermodel.UserId
	AsOwner bool // AsOwner is true if the user is the owner of the album
}

func OwnerAvailability added in v1.6.4

func OwnerAvailability(userId usermodel.UserId) Availability

func VisitorAvailability added in v1.6.4

func VisitorAvailability(userId usermodel.UserId) Availability

func (Availability) String added in v1.6.7

func (a Availability) String() string

type CommandHandlerAlbumSize added in v1.6.4

type CommandHandlerAlbumSize struct {
	MediaCounterPort              MediaCounterPort
	ListUserWhoCanAccessAlbumPort ListUserWhoCanAccessAlbumPort
	ViewWriteRepository           ViewWriteRepository
}

func (*CommandHandlerAlbumSize) AlbumShared added in v1.6.4

func (c *CommandHandlerAlbumSize) AlbumShared(ctx context.Context, albumId catalog.AlbumId, userId usermodel.UserId) error

func (*CommandHandlerAlbumSize) AlbumUnShared added in v1.6.4

func (c *CommandHandlerAlbumSize) AlbumUnShared(ctx context.Context, albumId catalog.AlbumId, userId usermodel.UserId) error

func (*CommandHandlerAlbumSize) OnMediasInserted added in v1.6.4

func (c *CommandHandlerAlbumSize) OnMediasInserted(ctx context.Context, medias map[catalog.AlbumId][]catalog.MediaId) error

func (*CommandHandlerAlbumSize) OnTransferredMedias added in v1.6.4

func (c *CommandHandlerAlbumSize) OnTransferredMedias(ctx context.Context, transfers catalog.TransferredMedias) error

type DeleteAlbumSizePort added in v1.6.7

type DeleteAlbumSizePort interface {
	DeleteAlbumSize(ctx context.Context, availability Availability, albumId catalog.AlbumId) error
}

type Drift added in v1.6.7

type Drift struct {
	Expected    *MissingOrInvalidDrift // Expected is exclusive from NotExpected, they can not be set together
	NotExpected *NotExpectedDrift      // NotExpected is exclusive from Expected, they can not be set together
}

func NewMissingDrift added in v1.6.7

func NewMissingDrift(size UserAlbumSize) Drift

func NewNotExpectedDrift added in v1.6.7

func NewNotExpectedDrift(availability Availability, albumId catalog.AlbumId) Drift

func NewOverrideDrift added in v1.6.7

func NewOverrideDrift(size UserAlbumSize) Drift

type DriftDetector added in v1.6.7

type DriftDetector struct {
	GetCurrentAlbumSizesPort GetCurrentAlbumSizesPort
	DriftObservers           []DriftObserver
}

func (*DriftDetector) InsertAlbumSize added in v1.6.7

func (d *DriftDetector) InsertAlbumSize(ctx context.Context, sizes []MultiUserAlbumSize) error

type DriftObserver added in v1.6.7

type DriftObserver interface {
	OnDetectedDrifts(ctx context.Context, drifts []Drift) error
}

type DriftOption added in v1.6.7

type DriftOption struct {
	// contains filtered or unexported fields
}

func DriftOptionDryMode added in v1.6.7

func DriftOptionDryMode(dry bool, synchronizer DriftSynchronizerPort) DriftOption

DriftOptionDryMode enable or not the DRY mode.

func DriftOptionObserver added in v1.6.7

func DriftOptionObserver(observer DriftObserver) DriftOption

DriftOptionObserver adds a custom observer.

func DriftOptionSynchronizer added in v1.6.7

func DriftOptionSynchronizer(synchronizer DriftSynchronizerPort) DriftOption

func (*DriftOption) Observer added in v1.6.7

func (o *DriftOption) Observer() DriftObserver

type DriftSynchronizerObserver added in v1.6.7

type DriftSynchronizerObserver struct {
	DriftSynchronizerPort DriftSynchronizerPort
}

func (*DriftSynchronizerObserver) OnDetectedDrifts added in v1.6.7

func (d *DriftSynchronizerObserver) OnDetectedDrifts(ctx context.Context, drifts []Drift) error

type DriftSynchronizerPort added in v1.6.7

type DriftSynchronizerPort interface {
	InsertAlbumSizePort
	DeleteAlbumSizePort
}

type FindAlbumByOwnerFunc added in v1.5.49

type FindAlbumByOwnerFunc func(ctx context.Context, owner ownermodel.Owner) ([]*catalog.Album, error)

func (FindAlbumByOwnerFunc) FindAlbumsByOwner added in v1.5.49

func (f FindAlbumByOwnerFunc) FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*catalog.Album, error)

type FindAlbumByOwnerPort

type FindAlbumByOwnerPort interface {
	FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*catalog.Album, error)
}

type FindAlbumsByIdsFunc added in v1.5.49

type FindAlbumsByIdsFunc func(ctx context.Context, ids []catalog.AlbumId) ([]*catalog.Album, error)

func (FindAlbumsByIdsFunc) FindAlbumsById added in v1.5.49

func (f FindAlbumsByIdsFunc) FindAlbumsById(ctx context.Context, ids []catalog.AlbumId) ([]*catalog.Album, error)

type FindAlbumsByIdsPort

type FindAlbumsByIdsPort interface {
	FindAlbumsById(ctx context.Context, ids []catalog.AlbumId) ([]*catalog.Album, error)
}

type GetAlbumSharingGridFunc added in v1.5.49

type GetAlbumSharingGridFunc func(ctx context.Context, owner ownermodel.Owner) (map[catalog.AlbumId][]usermodel.UserId, error)

func (GetAlbumSharingGridFunc) GetAlbumSharingGrid added in v1.5.49

func (f GetAlbumSharingGridFunc) GetAlbumSharingGrid(ctx context.Context, owner ownermodel.Owner) (map[catalog.AlbumId][]usermodel.UserId, error)

type GetAlbumSharingGridPort added in v1.5.49

type GetAlbumSharingGridPort interface {
	GetAlbumSharingGrid(ctx context.Context, owner ownermodel.Owner) (map[catalog.AlbumId][]usermodel.UserId, error)
}

type GetAvailabilitiesByUserPort added in v1.6.4

type GetAvailabilitiesByUserPort interface {
	GetAvailabilitiesByUser(ctx context.Context, userId usermodel.UserId) ([]UserAlbumSize, error)
}

type GetCurrentAlbumSizesPort added in v1.6.7

type GetCurrentAlbumSizesPort interface {
	GetAlbumSizes(ctx context.Context, userId usermodel.UserId, owner ...ownermodel.Owner) ([]UserAlbumSize, error)
}

type InsertAlbumSizePort added in v1.6.7

type InsertAlbumSizePort interface {
	InsertAlbumSize(ctx context.Context, albumSize []MultiUserAlbumSize) error
}

type ListAlbumsFilter

type ListAlbumsFilter struct {
	OnlyDirectlyOwned bool // OnlyDirectlyOwned provides a sub-view where only resources directly owned by user are displayed and accessible
}

type ListAlbumsProvider added in v1.5.49

type ListAlbumsProvider interface {
	ListAlbums(ctx context.Context, user usermodel.CurrentUser, filter ListAlbumsFilter) ([]*VisibleAlbum, error)
}

type ListAlbumsProviderFunc added in v1.5.49

type ListAlbumsProviderFunc func(ctx context.Context, user usermodel.CurrentUser, filter ListAlbumsFilter) ([]*VisibleAlbum, error)

func (ListAlbumsProviderFunc) ListAlbums added in v1.5.49

type ListUserWhoCanAccessAlbumPort added in v1.6.4

type ListUserWhoCanAccessAlbumPort interface {
	ListUsersWhoCanAccessAlbum(ctx context.Context, albumId ...catalog.AlbumId) (map[catalog.AlbumId][]Availability, error)
}

type LoggerDriftObserver added in v1.6.7

type LoggerDriftObserver struct{}

func (LoggerDriftObserver) OnDetectedDrifts added in v1.6.7

func (l LoggerDriftObserver) OnDetectedDrifts(ctx context.Context, drifts []Drift) error

type LoggingInsertAlbumSizeObserver added in v1.6.7

type LoggingInsertAlbumSizeObserver struct {
}

func (*LoggingInsertAlbumSizeObserver) InsertAlbumSize added in v1.6.7

func (l *LoggingInsertAlbumSizeObserver) InsertAlbumSize(ctx context.Context, albumSizes []MultiUserAlbumSize) error

type MediaCounterFromView added in v1.6.4

type MediaCounterFromView struct {
	AlbumSizes []AlbumSize
}

func (*MediaCounterFromView) CountMedia added in v1.6.4

func (m *MediaCounterFromView) CountMedia(ctx context.Context, album ...catalog.AlbumId) (map[catalog.AlbumId]int, error)

type MediaCounterFunc added in v1.5.50

type MediaCounterFunc func(ctx context.Context, album ...catalog.AlbumId) (map[catalog.AlbumId]int, error)

func (MediaCounterFunc) CountMedia added in v1.5.50

func (f MediaCounterFunc) CountMedia(ctx context.Context, album ...catalog.AlbumId) (map[catalog.AlbumId]int, error)

type MediaCounterInjector added in v1.6.4

type MediaCounterInjector struct {
	GetAvailabilitiesByUserPort GetAvailabilitiesByUserPort
	ProviderFactories           []ProviderFactory
}

MediaCounterInjector is covering the function while the view only contains some of the data (the counts)

func (*MediaCounterInjector) ListAlbums added in v1.6.4

type MediaCounterPort added in v1.5.50

type MediaCounterPort interface {
	CountMedia(ctx context.Context, album ...catalog.AlbumId) (map[catalog.AlbumId]int, error)
}

type MissingOrInvalidDrift added in v1.6.7

type MissingOrInvalidDrift struct {
	AvailableAlbumSize UserAlbumSize
	Missing            bool
}

type MultiUserAlbumSize added in v1.6.7

type MultiUserAlbumSize struct {
	AlbumSize
	Users []Availability
}

func (MultiUserAlbumSize) String added in v1.6.7

func (a MultiUserAlbumSize) String() string

type NotExpectedDrift added in v1.6.7

type NotExpectedDrift struct {
	Availability Availability
	AlbumId      catalog.AlbumId
}

type OwnedAlbumListProvider added in v1.5.49

type OwnedAlbumListProvider struct {
	FindAlbumByOwnerPort    FindAlbumByOwnerPort
	GetAlbumSharingGridPort GetAlbumSharingGridPort
	MediaCounterPort        MediaCounterPort
}

func (*OwnedAlbumListProvider) ListAlbums added in v1.5.49

type OwnerDriftReconciler added in v1.6.7

type OwnerDriftReconciler struct {
	FindAlbumByOwnerPort     FindAlbumByOwnerPort
	GetCurrentAlbumSizesPort GetCurrentAlbumSizesPort
	AlbumReCounter           AlbumReCounter
	DriftDetector            *DriftDetector
}

func NewDriftReconciler added in v1.6.7

func NewDriftReconciler(
	findAlbumByOwnerPort FindAlbumByOwnerPort,
	getCurrentAlbumSizesPort GetCurrentAlbumSizesPort,
	listUserWhoCanAccessAlbumPort ListUserWhoCanAccessAlbumPort,
	mediaCounterPort MediaCounterPort,
	DriftObservers ...DriftOption,
) *OwnerDriftReconciler

NewDriftReconciler creates a new DriftReconciler in DRY mode ; use the option DriftOptionSynchronizer to reconcile.

func (*OwnerDriftReconciler) Reconcile added in v1.6.7

func (d *OwnerDriftReconciler) Reconcile(ctx context.Context, owner ownermodel.Owner) error

Reconcile is re-computing counts for each album

type ProviderFactory added in v1.6.4

type ProviderFactory interface {
	NewProvider(ctx context.Context, mediaCounterPort MediaCounterPort) ListAlbumsProvider
}

type ProviderFactoryFunc added in v1.6.4

type ProviderFactoryFunc func(ctx context.Context, mediaCounterPort MediaCounterPort) ListAlbumsProvider

func (ProviderFactoryFunc) NewProvider added in v1.6.4

func (f ProviderFactoryFunc) NewProvider(ctx context.Context, mediaCounterPort MediaCounterPort) ListAlbumsProvider

type SharedAlbumListProvider added in v1.5.49

type SharedAlbumListProvider struct {
	FindAlbumsByIdsPort FindAlbumsByIdsPort
	SharedWithUserPort  SharedWithUserPort
	MediaCounterPort    MediaCounterPort
}

func (*SharedAlbumListProvider) ListAlbums added in v1.5.49

type SharedWithUserFunc added in v1.5.49

type SharedWithUserFunc func(ctx context.Context, userId usermodel.UserId) ([]catalog.AlbumId, error)

func (SharedWithUserFunc) ListAlbumIdsSharedWithUser added in v1.5.49

func (f SharedWithUserFunc) ListAlbumIdsSharedWithUser(ctx context.Context, userId usermodel.UserId) ([]catalog.AlbumId, error)

type SharedWithUserPort

type SharedWithUserPort interface {
	ListAlbumIdsSharedWithUser(ctx context.Context, userId usermodel.UserId) ([]catalog.AlbumId, error)
}

type UserAlbumSize added in v1.6.7

type UserAlbumSize struct {
	AlbumSize    AlbumSize
	Availability Availability
}

func (UserAlbumSize) ToMultiUser added in v1.6.7

func (s UserAlbumSize) ToMultiUser() MultiUserAlbumSize

type ViewWriteRepository added in v1.6.4

type ViewWriteRepository interface {
	InsertAlbumSizePort
	DeleteAlbumSizePort
	UpdateAlbumSize(ctx context.Context, albumCountUpdates []AlbumSizeDiff) error
}

type VisibleAlbum

type VisibleAlbum struct {
	catalog.Album
	MediaCount         int                // MediaCount is the number of medias on the album
	Visitors           []usermodel.UserId // Visitors are the users that can see the album ; only visible to the owner of the album
	OwnedByCurrentUser bool               // OwnedByCurrentUser is set to true when the user is an owner of the album
}

Jump to

Keyboard shortcuts

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