SyncArtistJob
extends BaseJob
in package
implements
ShouldQueue
uses
Dispatchable, InteractsWithQueue, Queueable, SerializesModels, UpdatesArtistMetadata
Table of Contents
Interfaces
- ShouldQueue
Properties
- $artistId : int
- $cascade : bool
- $forceUpdate : bool
- $logger : LoggerInterface
- $loggerCache : array<string|int, mixed>
- $progressCurrentChunk : int
- Internal variable used for tracking chunking progress.
- $progressLastUpdated : int|null
- The unix timestamp explaining the last time a progress has been written to database.
- $sources : array<string|int, mixed>
Methods
- __construct() : mixed
- handle() : void
- keepMonitorOnSuccess() : bool
- Weather to keep successful monitor models. This can be used if you only want to keep failed monitors for jobs that are frequently executed but worth to monitor. You are free to use the Laravel built-in failed job procedures.
- progressCooldown() : int
- The time in seconds to wait before a following queue progress update will be issued.
- queueData() : void
- Set Monitor data.
- queueProgress() : void
- Update progress.
- queueProgressChunk() : void
- Automatically update the current progress in each chunk iteration.
- syncAll() : self
- syncFromDiscogs() : self
- syncFromMusicBrainz() : self
- syncGeneral() : self
- syncIdentifierBased() : self
- deleteQueueMonitor() : void
- Delete Queue Monitor object.
- getFieldMappings() : array<string|int, mixed>
- getLogger() : LoggerInterface
- getQueueMonitor() : QueueMonitor|null
- Return Queue Monitor Model.
- processComplexFields() : array<string|int, mixed>
- fetchDataFromSource() : array<string|int, mixed>|null
- fetchFromDiscogs() : array<string|int, mixed>|null
- fetchFromGeneral() : array<string|int, mixed>|null
- fetchFromMusicBrainz() : array<string|int, mixed>|null
- getLogChannelAttribute() : LogChannel|null
- hasIdentifierFields() : bool
- isHigherQualityData() : bool
- isQueueProgressOnCooldown() : bool
- Check if the monitor should skip writing the progress to database avoiding rapid update queries.
- scheduleIdentifierBasedSync() : void
- shouldInitializeLogger() : bool
- shouldUpdateField() : bool
- syncFromSource() : array<string|int, mixed>
- updateArtistMetadata() : array<string|int, mixed>
Properties
$artistId read-only
private
int
$artistId
$cascade read-only
private
bool
$cascade
= true
$forceUpdate read-only
private
bool
$forceUpdate
= false
$logger
private
LoggerInterface
$logger
Attributes
- #[LogChannel]
- $channel: \App\Modules\Logging\Channel::Metadata
$loggerCache
private
array<string|int, mixed>
$loggerCache
= []
$progressCurrentChunk
Internal variable used for tracking chunking progress.
private
int
$progressCurrentChunk
= 0
$progressLastUpdated
The unix timestamp explaining the last time a progress has been written to database.
private
int|null
$progressLastUpdated
$sources read-only
private
array<string|int, mixed>
$sources
= ['general']
Methods
__construct()
public
__construct(int $artistId[, bool $forceUpdate = false ][, array<string|int, mixed> $sources = ['general'] ][, bool $cascade = true ]) : mixed
Parameters
- $artistId : int
- $forceUpdate : bool = false
- $sources : array<string|int, mixed> = ['general']
- $cascade : bool = true
handle()
public
handle() : void
keepMonitorOnSuccess()
Weather to keep successful monitor models. This can be used if you only want to keep failed monitors for jobs that are frequently executed but worth to monitor. You are free to use the Laravel built-in failed job procedures.
public
static keepMonitorOnSuccess() : bool
Return values
boolprogressCooldown()
The time in seconds to wait before a following queue progress update will be issued.
public
progressCooldown() : int
This is used to avoid writing many progress updates to the database. 0 = no delay.
Return values
intqueueData()
Set Monitor data.
public
queueData(array<string|int, mixed> $data[, bool $merge = false ]) : void
Parameters
- $data : array<string|int, mixed>
-
Custom data
- $merge : bool = false
-
Merge the data instead of overriding
queueProgress()
Update progress.
public
queueProgress(int $progress) : void
Parameters
- $progress : int
-
Progress as integer 0-100
queueProgressChunk()
Automatically update the current progress in each chunk iteration.
public
queueProgressChunk(int $collectionCount, int $perChunk) : void
Parameters
- $collectionCount : int
-
The total collection item amount
- $perChunk : int
-
The size of each chunk
syncAll()
public
static syncAll(int $artistId[, bool $forceUpdate = false ]) : self
Parameters
- $artistId : int
- $forceUpdate : bool = false
Return values
selfsyncFromDiscogs()
public
static syncFromDiscogs(int $artistId[, bool $forceUpdate = false ]) : self
Parameters
- $artistId : int
- $forceUpdate : bool = false
Return values
selfsyncFromMusicBrainz()
public
static syncFromMusicBrainz(int $artistId[, bool $forceUpdate = false ]) : self
Parameters
- $artistId : int
- $forceUpdate : bool = false
Return values
selfsyncGeneral()
public
static syncGeneral(int $artistId[, bool $forceUpdate = false ]) : self
Parameters
- $artistId : int
- $forceUpdate : bool = false
Return values
selfsyncIdentifierBased()
public
static syncIdentifierBased(int $artistId[, bool $forceUpdate = false ]) : self
Parameters
- $artistId : int
- $forceUpdate : bool = false
Return values
selfdeleteQueueMonitor()
Delete Queue Monitor object.
protected
deleteQueueMonitor() : void
getFieldMappings()
protected
getFieldMappings(string $source) : array<string|int, mixed>
Parameters
- $source : string
Return values
array<string|int, mixed>getLogger()
protected
getLogger([string $propertyName = 'logger' ]) : LoggerInterface
Parameters
- $propertyName : string = 'logger'
Return values
LoggerInterfacegetQueueMonitor()
Return Queue Monitor Model.
protected
getQueueMonitor() : QueueMonitor|null
Return values
QueueMonitor|nullprocessComplexFields()
protected
processComplexFields(Artist $artist, array<string|int, mixed> $data, string $source) : array<string|int, mixed>
Parameters
- $artist : Artist
- $data : array<string|int, mixed>
- $source : string
Return values
array<string|int, mixed>fetchDataFromSource()
private
fetchDataFromSource(Artist $artist, string $source) : array<string|int, mixed>|null
Parameters
- $artist : Artist
- $source : string
Return values
array<string|int, mixed>|nullfetchFromDiscogs()
private
fetchFromDiscogs(Artist $artist) : array<string|int, mixed>|null
Parameters
- $artist : Artist
Return values
array<string|int, mixed>|nullfetchFromGeneral()
private
fetchFromGeneral(Artist $artist) : array<string|int, mixed>|null
Parameters
- $artist : Artist
Return values
array<string|int, mixed>|nullfetchFromMusicBrainz()
private
fetchFromMusicBrainz(Artist $artist) : array<string|int, mixed>|null
Parameters
- $artist : Artist
Return values
array<string|int, mixed>|nullgetLogChannelAttribute()
private
getLogChannelAttribute(ReflectionProperty $property) : LogChannel|null
Parameters
- $property : ReflectionProperty
Return values
LogChannel|nullhasIdentifierFields()
private
hasIdentifierFields(array<string|int, mixed> $fields) : bool
Parameters
- $fields : array<string|int, mixed>
Return values
boolisHigherQualityData()
private
isHigherQualityData(mixed $existing, mixed $new) : bool
Parameters
- $existing : mixed
- $new : mixed
Return values
boolisQueueProgressOnCooldown()
Check if the monitor should skip writing the progress to database avoiding rapid update queries.
private
isQueueProgressOnCooldown(int $progress) : bool
The progress values 0, 25, 50, 75 and 100 will always be written.
Parameters
- $progress : int
Return values
boolscheduleIdentifierBasedSync()
private
scheduleIdentifierBasedSync(Artist $artist) : void
Parameters
- $artist : Artist
shouldInitializeLogger()
private
shouldInitializeLogger(ReflectionProperty $property) : bool
Parameters
- $property : ReflectionProperty
Return values
boolshouldUpdateField()
private
shouldUpdateField(Artist $artist, string $field, mixed $value) : bool
Parameters
- $artist : Artist
- $field : string
- $value : mixed
Return values
boolsyncFromSource()
private
syncFromSource(Artist $artist, string $source) : array<string|int, mixed>
Parameters
- $artist : Artist
- $source : string
Return values
array<string|int, mixed>updateArtistMetadata()
private
updateArtistMetadata(Artist $artist, array<string|int, mixed> $data, string $source) : array<string|int, mixed>
Parameters
- $artist : Artist
- $data : array<string|int, mixed>
- $source : string