Documentation ¶
Index ¶
- type AppearanceType
- type AppearancesByYears
- type AppearancesByYearsMapRepository
- type AppearancesByYearsRepository
- type AppearancesByYearsWriter
- type AppearancesSyncer
- type AvgIssuesPerYearRank
- type Character
- type CharacterCriteria
- type CharacterID
- type CharacterIssue
- type CharacterIssueID
- type CharacterIssueRepository
- type CharacterRepository
- type CharacterService
- func (s *CharacterService) BothAppearances(slug CharacterSlug) (AppearancesByYears, error)
- func (s *CharacterService) Character(slug CharacterSlug) (*Character, error)
- func (s *CharacterService) CharacterByVendor(vendorID string, vendorType VendorType, includeIsDisabled bool) (*Character, error)
- func (s *CharacterService) Characters(slugs []CharacterSlug, limit, offset int) ([]*Character, error)
- func (s *CharacterService) CharactersByPublisher(slugs []PublisherSlug, filterSources bool, limit, offset int) ([]*Character, error)
- func (s *CharacterService) CharactersWithSources(slugs []CharacterSlug, limit, offset int) ([]*Character, error)
- func (s *CharacterService) Create(c *Character) error
- func (s *CharacterService) CreateIssue(issue *CharacterIssue) error
- func (s *CharacterService) CreateIssueP(characterID CharacterID, issueID IssueID, appearanceType AppearanceType, ...) (*CharacterIssue, error)
- func (s *CharacterService) CreateIssues(issues []*CharacterIssue) error
- func (s *CharacterService) CreateSource(source *CharacterSource) error
- func (s *CharacterService) CreateSyncLog(syncLog *CharacterSyncLog) error
- func (s *CharacterService) CreateSyncLogP(id CharacterID, status CharacterSyncLogStatus, syncType CharacterSyncLogType, ...) (*CharacterSyncLog, error)
- func (s *CharacterService) Issue(characterID CharacterID, issueID IssueID) (*CharacterIssue, error)
- func (s *CharacterService) ListAppearances(slug CharacterSlug) ([]AppearancesByYears, error)
- func (s *CharacterService) MustNormalizeSources(c *Character)
- func (s *CharacterService) Source(id CharacterID, vendorURL string) (*CharacterSource, error)
- func (s *CharacterService) Sources(id CharacterID, vendorType VendorType, isMain *bool) ([]*CharacterSource, error)
- func (s *CharacterService) TotalSources(id CharacterID) (int64, error)
- func (s *CharacterService) Update(c *Character) error
- func (s *CharacterService) UpdateAll(characters []*Character) error
- func (s *CharacterService) UpdateSource(source *CharacterSource) error
- func (s *CharacterService) UpdateSyncLog(syncLog *CharacterSyncLog) error
- type CharacterServicer
- type CharacterSlug
- type CharacterSource
- type CharacterSourceCriteria
- type CharacterSourceID
- type CharacterSourceRepository
- type CharacterSyncLog
- func NewCharacterSyncLog(id CharacterID, status CharacterSyncLogStatus, syncedAt *time.Time) *CharacterSyncLog
- func NewSyncLog(id CharacterID, status CharacterSyncLogStatus, t CharacterSyncLogType, ...) *CharacterSyncLog
- func NewSyncLogPending(id CharacterID, syncLogType CharacterSyncLogType) *CharacterSyncLog
- type CharacterSyncLogID
- type CharacterSyncLogRepository
- type CharacterSyncLogStatus
- type CharacterSyncLogType
- type Format
- type Importance
- type Issue
- type IssueCountRank
- type IssueCriteria
- type IssueID
- type IssueRepository
- type IssueService
- func (s *IssueService) Create(i *Issue) error
- func (s *IssueService) CreateP(vendorID, vendorPublisher, vendorSeriesName, vendorSeriesNumber string, ...) error
- func (s *IssueService) Issues(ids []IssueID, limit, offset int) ([]*Issue, error)
- func (s *IssueService) IssuesByVendor(ids []string, vendorType VendorType, limit, offset int) ([]*Issue, error)
- type IssueServicer
- type PGAppearancesByYearsRepository
- func (r *PGAppearancesByYearsRepository) Alternate(slug CharacterSlug) (AppearancesByYears, error)
- func (r *PGAppearancesByYearsRepository) Both(slug CharacterSlug) (AppearancesByYears, error)
- func (r *PGAppearancesByYearsRepository) List(slugs ...CharacterSlug) ([]AppearancesByYears, error)
- func (r *PGAppearancesByYearsRepository) Main(slug CharacterSlug) (AppearancesByYears, error)
- type PGCharacterIssueRepository
- func (r *PGCharacterIssueRepository) Create(ci *CharacterIssue) error
- func (r *PGCharacterIssueRepository) CreateAll(issues []*CharacterIssue) error
- func (r *PGCharacterIssueRepository) FindOneBy(characterID CharacterID, issueID IssueID) (*CharacterIssue, error)
- func (r *PGCharacterIssueRepository) InsertFast(issues []*CharacterIssue) error
- type PGCharacterRepository
- func (r *PGCharacterRepository) Create(c *Character) error
- func (r *PGCharacterRepository) FindAll(cr CharacterCriteria) ([]*Character, error)
- func (r *PGCharacterRepository) FindBySlug(slug CharacterSlug, includeIsDisabled bool) (*Character, error)
- func (r *PGCharacterRepository) Remove(id CharacterID) error
- func (r *PGCharacterRepository) Total(cr CharacterCriteria) (int64, error)
- func (r *PGCharacterRepository) Update(c *Character) error
- func (r *PGCharacterRepository) UpdateAll(characters []*Character) error
- type PGCharacterSourceRepository
- func (r *PGCharacterSourceRepository) Create(s *CharacterSource) error
- func (r *PGCharacterSourceRepository) FindAll(cr CharacterSourceCriteria) ([]*CharacterSource, error)
- func (r *PGCharacterSourceRepository) Raw(query string, params ...interface{}) error
- func (r *PGCharacterSourceRepository) Remove(id CharacterSourceID) error
- func (r *PGCharacterSourceRepository) Update(s *CharacterSource) error
- type PGCharacterSyncLogRepository
- func (r *PGCharacterSyncLogRepository) Create(s *CharacterSyncLog) error
- func (r *PGCharacterSyncLogRepository) FindAllByCharacterID(id CharacterID) ([]*CharacterSyncLog, error)
- func (r *PGCharacterSyncLogRepository) FindByID(id CharacterSyncLogID) (*CharacterSyncLog, error)
- func (r *PGCharacterSyncLogRepository) Update(l *CharacterSyncLog) error
- type PGIssueRepository
- func (r *PGIssueRepository) Create(issue *Issue) error
- func (r *PGIssueRepository) CreateAll(issues []*Issue) error
- func (r *PGIssueRepository) FindAll(cr IssueCriteria) ([]*Issue, error)
- func (r *PGIssueRepository) FindByVendorID(vendorID string) (*Issue, error)
- func (r *PGIssueRepository) Update(issue *Issue) error
- type PGPopularRepository
- type PGPublisherRepository
- type PGRepositoryContainer
- func (c *PGRepositoryContainer) AppearancesByYearsRepository() *PGAppearancesByYearsRepository
- func (c *PGRepositoryContainer) CharacterIssueRepository() CharacterIssueRepository
- func (c *PGRepositoryContainer) CharacterRepository() CharacterRepository
- func (c *PGRepositoryContainer) CharacterSourceRepository() CharacterSourceRepository
- func (c *PGRepositoryContainer) CharacterSyncLogRepository() CharacterSyncLogRepository
- func (c *PGRepositoryContainer) IssueRepository() IssueRepository
- func (c *PGRepositoryContainer) PublisherRepository() PublisherRepository
- func (c *PGRepositoryContainer) StatsRepository() StatsRepository
- type PGStatsRepository
- type PopularCriteria
- type PopularRepository
- type PopularSortCriteria
- type Publisher
- type PublisherID
- type PublisherRepository
- type PublisherService
- type PublisherServicer
- type PublisherSlug
- type RankedCharacter
- type RankedService
- type RankedServicer
- type RedisAppearancesByYearsRepository
- func (r *RedisAppearancesByYearsRepository) Alternate(slug CharacterSlug) (AppearancesByYears, error)
- func (r *RedisAppearancesByYearsRepository) Both(slug CharacterSlug) (AppearancesByYears, error)
- func (r *RedisAppearancesByYearsRepository) List(slugs ...CharacterSlug) ([]AppearancesByYears, error)
- func (r *RedisAppearancesByYearsRepository) ListMap(slugs ...CharacterSlug) (map[CharacterSlug][]AppearancesByYears, error)
- func (r *RedisAppearancesByYearsRepository) Main(slug CharacterSlug) (AppearancesByYears, error)
- func (r *RedisAppearancesByYearsRepository) Set(character AppearancesByYears) error
- type Stats
- type StatsRepository
- type Syncer
- type TrendingCriteria
- type VendorType
- type YearlyAggregate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppearanceType ¶
type AppearanceType uint8
AppearanceType is a type of appearance, such as an alternate universe or main character appearance. A bitwise enum representing the types of appearances. Main is 001 Alternate is 100 Both Main and Alternate would be 101 so: `Main | Alternate`
const ( // Main is their main universe(s) Main AppearanceType = 1 << 0 // Alternate is an alternate reality appearance or whatever. Alternate AppearanceType = 1 << 1 )
The types of appearances for a character issue. Bitwise values to represent appearance types.
func (AppearanceType) HasAll ¶
func (u AppearanceType) HasAll(flags AppearanceType) bool
HasAll checks that the category has all of the given flags.
func (AppearanceType) HasAny ¶
func (u AppearanceType) HasAny(flags AppearanceType) bool
HasAny checks that the category has any of the given flags.
func (AppearanceType) MarshalJSON ¶
func (u AppearanceType) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON string representation.
func (*AppearanceType) Scan ¶
func (u *AppearanceType) Scan(value interface{}) error
Scan for the ORM converting the enum.
type AppearancesByYears ¶
type AppearancesByYears struct { CharacterSlug CharacterSlug `json:"slug"` // The unique identifier for the character. Category AppearanceType `json:"category"` Aggregates []YearlyAggregate `json:"aggregates"` }
AppearancesByYears represents the key, category, and appearances categorized per year for a character.
func NewAppearancesByYears ¶
func NewAppearancesByYears(slug CharacterSlug, cat AppearanceType, aggs []YearlyAggregate) AppearancesByYears
NewAppearancesByYears creates a new struct with the parameters.
func (*AppearancesByYears) AddAppearance ¶
func (c *AppearancesByYears) AddAppearance(appearance YearlyAggregate) *AppearancesByYears
AddAppearance adds an appearance to the appearances for the character.
func (*AppearancesByYears) Total ¶
func (c *AppearancesByYears) Total() int
Total returns the total number of appearances per year.
type AppearancesByYearsMapRepository ¶
type AppearancesByYearsMapRepository interface {
ListMap(slugs ...CharacterSlug) (map[CharacterSlug][]AppearancesByYears, error)
}
AppearancesByYearsMapRepository is the repository for listing a character's appearances by years in a map.
func NewRedisAppearancesMapRepository ¶
func NewRedisAppearancesMapRepository(r *redis.Client) AppearancesByYearsMapRepository
NewRedisAppearancesMapRepository creates a new redis appearances map repository.
type AppearancesByYearsRepository ¶
type AppearancesByYearsRepository interface { Both(slug CharacterSlug) (AppearancesByYears, error) Main(slug CharacterSlug) (AppearancesByYears, error) Alternate(slug CharacterSlug) (AppearancesByYears, error) List(slugs ...CharacterSlug) ([]AppearancesByYears, error) }
AppearancesByYearsRepository is the repository interface for getting a characters appearances per year.
type AppearancesByYearsWriter ¶
type AppearancesByYearsWriter interface {
Set(apps AppearancesByYears) error
}
AppearancesByYearsWriter sets the appearances by years for a character.
func NewAppearancesByYearsWriter ¶
func NewAppearancesByYearsWriter(c *redis.Client) AppearancesByYearsWriter
type AppearancesSyncer ¶
type AppearancesSyncer struct {
// contains filtered or unexported fields
}
AppearancesSyncer to sync yearly appearances from Postgres to Redis.
func (*AppearancesSyncer) Sync ¶
func (s *AppearancesSyncer) Sync(slug CharacterSlug) (int, error)
Sync gets all the character's appearances from the database and syncs them to Redis. returns the total number of issues synced and an error if any.
type AvgIssuesPerYearRank ¶
type AvgIssuesPerYearRank uint
AvgIssuesPerYearRank is the rank for average issues per year.
type Character ¶
type Character struct { ID CharacterID `json:"-"` Publisher Publisher `json:"publisher"` PublisherID PublisherID `pg:",fk:publisher_id" sql:",notnull,on_delete:CASCADE" json:"-"` Name string `sql:",notnull" json:"name"` OtherName string `json:"other_name"` Description string `json:"description"` Image string `json:"image"` Slug CharacterSlug `sql:",notnull,unique:uix_character_slug" json:"slug"` VendorType VendorType `sql:",notnull,unique:uix_vendor_type_vendor_id" json:"-"` VendorID string `sql:",notnull,unique:uix_vendor_type_vendor_id" json:"-"` VendorImage string `json:"vendor_image"` VendorImageMd5 string `sql:",type:varchar(32)," json:"-"` VendorURL string `json:"vendor_url"` VendorDescription string `json:"vendor_description"` IsDisabled bool `json:"-" sql:",notnull"` CreatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
Character - A model for a character.
func NewCharacter ¶
func NewCharacter(name string, publisherID PublisherID, vendorType VendorType, vendorID string) *Character
NewCharacter Creates a new character.
func (*Character) MarshalJSON ¶
MarshalJSON overrides JSON marshaling for CDN url.
type CharacterCriteria ¶
type CharacterCriteria struct { IDs []CharacterID Slugs []CharacterSlug PublisherIDs []PublisherID PublisherSlugs []PublisherSlug FilterSources bool // Filter characters that only have sources. If false it returns characters regardless. FilterIssues bool // Filter characters that only have issues. If false it returns characters regardless. VendorTypes []VendorType // Include characters that are disabled. By default it does not. IncludeIsDisabled bool VendorIds []string Limit int Offset int }
CharacterCriteria for querying characters.
type CharacterIssue ¶
type CharacterIssue struct { ID CharacterIssueID Character *Character // Not eager-loaded. Could be nil. CharacterID CharacterID `pg:",fk:character_id" sql:",notnull,unique:uix_character_id_issue_id,on_delete:CASCADE"` Issue *Issue // Not eager-loaded. Could be nil. IssueID IssueID `pg:",fk:issue_id" sql:",notnull,unique:uix_character_id_issue_id,on_delete:CASCADE"` AppearanceType AppearanceType `sql:",notnull,type:bit(8),default:B'00000001'"` Importance *Importance `sql:",type:smallint"` CreatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
CharacterIssue references an issue for a character.
func NewCharacterIssue ¶
func NewCharacterIssue(characterID CharacterID, id IssueID, appearanceType AppearanceType) *CharacterIssue
NewCharacterIssue creates a new character issue struct.
type CharacterIssueID ¶
type CharacterIssueID uint
CharacterIssueID is the PK identifier for a character issue.
type CharacterIssueRepository ¶
type CharacterIssueRepository interface { CreateAll(cis []*CharacterIssue) error Create(ci *CharacterIssue) error FindOneBy(characterID CharacterID, issueID IssueID) (*CharacterIssue, error) InsertFast(issues []*CharacterIssue) error }
CharacterIssueRepository is the repository interface for character issues.
func NewPGCharacterIssueRepository ¶
func NewPGCharacterIssueRepository(db *pg.DB) CharacterIssueRepository
NewPGCharacterIssueRepository creates the new character issue repository for the postgres implementation.
type CharacterRepository ¶
type CharacterRepository interface { Create(c *Character) error Update(c *Character) error FindBySlug(slug CharacterSlug, includeIsDisabled bool) (*Character, error) FindAll(cr CharacterCriteria) ([]*Character, error) UpdateAll(characters []*Character) error Remove(id CharacterID) error Total(cr CharacterCriteria) (int64, error) }
CharacterRepository is the repository interface for characters.
func NewPGCharacterRepository ¶
func NewPGCharacterRepository(db *pg.DB) CharacterRepository
NewPGCharacterRepository creates the new character repository.
type CharacterService ¶
type CharacterService struct {
// contains filtered or unexported fields
}
CharacterService is the service for characters.
func (*CharacterService) BothAppearances ¶
func (s *CharacterService) BothAppearances(slug CharacterSlug) (AppearancesByYears, error)
BothAppearances lists the combination of main + alt appearances in one struct.
func (*CharacterService) Character ¶
func (s *CharacterService) Character(slug CharacterSlug) (*Character, error)
Character gets a non-disabled character by its slug.
func (*CharacterService) CharacterByVendor ¶
func (s *CharacterService) CharacterByVendor(vendorID string, vendorType VendorType, includeIsDisabled bool) (*Character, error)
CharacterByVendor gets a character from the specified vendor and whether the character is disabled or not.
func (*CharacterService) Characters ¶
func (s *CharacterService) Characters(slugs []CharacterSlug, limit, offset int) ([]*Character, error)
Characters gets all non-disabled characters by their slugs. A `limit` of `0` means unlimited.
func (*CharacterService) CharactersByPublisher ¶
func (s *CharacterService) CharactersByPublisher(slugs []PublisherSlug, filterSources bool, limit, offset int) ([]*Character, error)
CharactersByPublisher lists enabled characters by their publisher.
func (*CharacterService) CharactersWithSources ¶
func (s *CharacterService) CharactersWithSources(slugs []CharacterSlug, limit, offset int) ([]*Character, error)
CharactersWithSources gets non-disabled characters who have sources. A `limit` of `0` means unlimited.
func (*CharacterService) Create ¶
func (s *CharacterService) Create(c *Character) error
Create creates a new character
func (*CharacterService) CreateIssue ¶
func (s *CharacterService) CreateIssue(issue *CharacterIssue) error
CreateIssue creates an issue.
func (*CharacterService) CreateIssueP ¶
func (s *CharacterService) CreateIssueP(characterID CharacterID, issueID IssueID, appearanceType AppearanceType, importance *Importance) (*CharacterIssue, error)
CreateIssueP creates an issue from the parameters.
func (*CharacterService) CreateIssues ¶
func (s *CharacterService) CreateIssues(issues []*CharacterIssue) error
CreateIssues creates multiple issues in a bulk query. TODO: Generated ID doesn't get set!
func (*CharacterService) CreateSource ¶
func (s *CharacterService) CreateSource(source *CharacterSource) error
CreateSource creates a source for a character, if it doesn't exist. If it exists, an ErrAlreadyExists gets returned as an error. A little janky right now.
func (*CharacterService) CreateSyncLog ¶
func (s *CharacterService) CreateSyncLog(syncLog *CharacterSyncLog) error
CreateSyncLog creates a sync log for a character.
func (*CharacterService) CreateSyncLogP ¶
func (s *CharacterService) CreateSyncLogP(id CharacterID, status CharacterSyncLogStatus, syncType CharacterSyncLogType, syncedAt *time.Time) (*CharacterSyncLog, error)
CreateSyncLogP creates a sync log with the parameters.
func (*CharacterService) Issue ¶
func (s *CharacterService) Issue(characterID CharacterID, issueID IssueID) (*CharacterIssue, error)
Issue gets a character issue by its character ID and issue ID.
func (*CharacterService) ListAppearances ¶
func (s *CharacterService) ListAppearances(slug CharacterSlug) ([]AppearancesByYears, error)
ListAppearances lists both main and alternate appearances.
func (*CharacterService) MustNormalizeSources ¶
func (s *CharacterService) MustNormalizeSources(c *Character)
MustNormalizeSources normalizes sources for main and alternate sources and disables any unneeded sources.
func (*CharacterService) Source ¶
func (s *CharacterService) Source(id CharacterID, vendorURL string) (*CharacterSource, error)
Source gets a unique character source by its character ID and vendor url
func (*CharacterService) Sources ¶
func (s *CharacterService) Sources(id CharacterID, vendorType VendorType, isMain *bool) ([]*CharacterSource, error)
Sources lists all non-disabled character sources from the given parameters. If `isMain` is `nil`, it will list both types of sources. If `isMain` is true, it will list main sources. If `isMain` is `false`, it will list alternate sources.
func (*CharacterService) TotalSources ¶
func (s *CharacterService) TotalSources(id CharacterID) (int64, error)
TotalSources gets the total number of sources for a character
func (*CharacterService) Update ¶
func (s *CharacterService) Update(c *Character) error
Update updates a character.
func (*CharacterService) UpdateAll ¶
func (s *CharacterService) UpdateAll(characters []*Character) error
UpdateAll updates all characters
func (*CharacterService) UpdateSource ¶
func (s *CharacterService) UpdateSource(source *CharacterSource) error
UpdateSource updates an existing source
func (*CharacterService) UpdateSyncLog ¶
func (s *CharacterService) UpdateSyncLog(syncLog *CharacterSyncLog) error
UpdateSyncLog updates a sync log for a character.
type CharacterServicer ¶
type CharacterServicer interface { // Creates a character Create(character *Character) error // Character gets a character by its slug. Character(slug CharacterSlug) (*Character, error) // Updates a character. Update(character *Character) error // UpdateAll updates all characters UpdateAll(characters []*Character) error // CharactersWithSources gets all the enabled characters who have sources. CharactersWithSources(slug []CharacterSlug, limit, offset int) ([]*Character, error) // Characters gets all enabled characters by their slugs. Characters(slugs []CharacterSlug, limit, offset int) ([]*Character, error) // CharacterByVendor gets all the characters by the vendor. If `includeIsDisabled` is true, it will include disabled characters. CharacterByVendor(vendorID string, vendorType VendorType, includeIsDisabled bool) (*Character, error) // CharactersByPublisher list characters alphabetically. If `filterSources` is true, it will only list characters with sources. CharactersByPublisher(slugs []PublisherSlug, filterSources bool, limit, offset int) ([]*Character, error) // CreateSource creates a character source if it doesn't exist. If it exists, it returns the found source and an error. // And also modifies `source` to get the found values. CreateSource(source *CharacterSource) error // UpdateSource updates a character source UpdateSource(source *CharacterSource) error // MustNormalizeSources so that main vs alternate sources are categorized correctly and disables any unnecessary sources. // panics if there's an error. MustNormalizeSources(*Character) // Source gets a unique source by its character ID and vendor url. Source(id CharacterID, vendorURL string) (*CharacterSource, error) // Sources gets all the sources for a character. Sources(id CharacterID, vendorType VendorType, isMain *bool) ([]*CharacterSource, error) // TotalSources gets the total sources for a character. TotalSources(id CharacterID) (int64, error) // CreateIssueP creates an issue for a character with the parameters. CreateIssueP( characterID CharacterID, issueID IssueID, appearanceType AppearanceType, importance *Importance) (*CharacterIssue, error) // CreateIssue creates an issue for a character. CreateIssue(issue *CharacterIssue) error // CreateIssues creates multiple issues for a character. // TODO: Autogenerated IDs not returned in struct!! CreateIssues(issues []*CharacterIssue) error // Issue gets a character issue by its character ID and issue ID Issue(characterID CharacterID, issueID IssueID) (*CharacterIssue, error) // CreateSyncLogP creates a sync log for a character with the parameters. CreateSyncLogP( id CharacterID, status CharacterSyncLogStatus, syncType CharacterSyncLogType, syncedAt *time.Time) (*CharacterSyncLog, error) // CreateSyncLog creates a sync log. CreateSyncLog(syncLog *CharacterSyncLog) error // UpdateSyncLog updates a sync log UpdateSyncLog(syncLog *CharacterSyncLog) error // BothAppearances gets the combined appearances for main + alternate BothAppearances(slug CharacterSlug) (AppearancesByYears, error) // ListAppearances gets main and alternate appearances as lists (so not combined) ListAppearances(slug CharacterSlug) ([]AppearancesByYears, error) }
CharacterServicer is the service interface for characters.
func NewCharacterService ¶
func NewCharacterService(container *PGRepositoryContainer) CharacterServicer
NewCharacterService creates a new character service but with the appearances by years coming from postgres.
func NewCharacterServiceWithCache ¶
func NewCharacterServiceWithCache(container *PGRepositoryContainer, redis *redis.Client) CharacterServicer
NewCharacterServiceWithCache creates a new character service but with the appearances by years coming from the Redis cache.
type CharacterSlug ¶
type CharacterSlug string
CharacterSlug is the unique slug for the character.
func NewCharacterSlugs ¶
func NewCharacterSlugs(strs ...string) []CharacterSlug
NewCharacterSlugs creates character slugs from the specified `strs` string.
type CharacterSource ¶
type CharacterSource struct { ID CharacterSourceID `json:"id"` Character *Character // Pointer. Could be nil. Not eager-loaded. CharacterID CharacterID `pg:",fk:character_id" sql:",notnull,unique:uix_character_id_vendor_url,on_delete:CASCADE" json:"character_id"` VendorType VendorType `sql:",notnull,type:smallint" json:"type"` VendorURL string `sql:",notnull,unique:uix_character_id_vendor_url"` VendorName string `sql:",notnull"` VendorOtherName string IsDisabled bool `sql:",notnull"` IsMain bool `sql:",notnull"` CreatedAt time.Time `sql:",default:NOW(),notnull" json:"-"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
CharacterSource contains external profile links to the character.
func NewCharacterSource ¶
func NewCharacterSource(url, name string, id CharacterID, vendorType VendorType) *CharacterSource
NewCharacterSource creates a new character source struct.
type CharacterSourceCriteria ¶
type CharacterSourceCriteria struct { CharacterIDs []CharacterID VendorUrls []string VendorType VendorType // If IsMain is null, it will return both. IsMain *bool // Include sources that are disabled. By default it does not include disabled sources. IncludeIsDisabled bool Limit int Offset int }
CharacterSourceCriteria for querying character sources.
type CharacterSourceID ¶
type CharacterSourceID uint
CharacterSourceID is the PK identifier for the character source struct.
type CharacterSourceRepository ¶
type CharacterSourceRepository interface { Create(s *CharacterSource) error FindAll(criteria CharacterSourceCriteria) ([]*CharacterSource, error) Remove(id CharacterSourceID) error // Raw runs a raw query on the character sources. Raw(query string, params ...interface{}) error Update(s *CharacterSource) error }
CharacterSourceRepository is the repository interface for character sources.
func NewPGCharacterSourceRepository ¶
func NewPGCharacterSourceRepository(db *pg.DB) CharacterSourceRepository
NewPGCharacterSourceRepository creates the new character source repository for the postgres implementation.
type CharacterSyncLog ¶
type CharacterSyncLog struct { ID CharacterSyncLogID `json:"id"` SyncType CharacterSyncLogType `sql:",notnull,type:smallint" json:"type"` SyncStatus CharacterSyncLogStatus `sql:",notnull,type:smallint" json:"status"` Message string SyncedAt *time.Time `json:"synced_at"` Character *Character // Not eager-loaded, could be nil. CharacterID CharacterID `pg:",fk:character_id" sql:",notnull,on_delete:CASCADE" json:"character_id"` CreatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
CharacterSyncLog contains information pertaining to syncs for the character.
func NewCharacterSyncLog ¶
func NewCharacterSyncLog(id CharacterID, status CharacterSyncLogStatus, syncedAt *time.Time) *CharacterSyncLog
NewCharacterSyncLog creates a new sync log object for syncing characters.
func NewSyncLog ¶
func NewSyncLog( id CharacterID, status CharacterSyncLogStatus, t CharacterSyncLogType, syncedAt *time.Time) *CharacterSyncLog
NewSyncLog Creates a pointer to a new sync log object for the yearly appearances category.
func NewSyncLogPending ¶
func NewSyncLogPending( id CharacterID, syncLogType CharacterSyncLogType) *CharacterSyncLog
NewSyncLogPending creates a new pending sync log struct for the specified type.
type CharacterSyncLogID ¶
type CharacterSyncLogID uint
CharacterSyncLogID is the PK identifier for character sync logs.
func (CharacterSyncLogID) Value ¶
func (id CharacterSyncLogID) Value() uint
Value returns the raw value.
type CharacterSyncLogRepository ¶
type CharacterSyncLogRepository interface { Create(s *CharacterSyncLog) error FindAllByCharacterID(characterID CharacterID) ([]*CharacterSyncLog, error) Update(s *CharacterSyncLog) error FindByID(id CharacterSyncLogID) (*CharacterSyncLog, error) }
CharacterSyncLogRepository is the repository interface for character sync logs.
func NewPGCharacterSyncLogRepository ¶
func NewPGCharacterSyncLogRepository(db *pg.DB) CharacterSyncLogRepository
NewPGCharacterSyncLogRepository creates the new character sync log repository.
type CharacterSyncLogStatus ¶
type CharacterSyncLogStatus int
CharacterSyncLogStatus is the status of the sync.
const ( // Pending - when a sync is pending and waiting in the queue. Pending CharacterSyncLogStatus = iota + 1 // InProgress - when a sync is currently in progress and tallying appearances. InProgress // Fail - when a sync failed. Fail // Success - when a sync succeeded. Success )
Constants for character sync log statuses.
type CharacterSyncLogType ¶
type CharacterSyncLogType int
CharacterSyncLogType is the type of sync that occurred for the character.
const ( // YearlyAppearances is the syncing for yearly appearances. YearlyAppearances CharacterSyncLogType = iota + 1 // Characters is the syncing for characters. Characters )
Constants for character sync log types.
type Format ¶
type Format string
Format is the format for the issue.
const ( FormatUnknown Format = "unknown" FormatStandard Format = "standard" FormatTPB Format = "tpb" FormatManga Format = "manga" FormatHC Format = "hc" FormatOGN Format = "ogn" FormatWeb Format = "web" FormatAnthology Format = "anthology" FormatMagazine Format = "magazine" FormatDigitalMedia Format = "digital" FormatMiniComic Format = "mini" FormatFlipbook Format = "flipbook" FormatPrestige Format = "prestige" FormatOther Format = "other" )
The format types for the issue.
type Importance ¶
type Importance int
Importance -- for a later feature -- ranks a character issue by the character's importance in the issue.
const ( // Cameo - they just make a cameo appearance Cameo Importance = iota + 1 // Minor - meh, minor Minor // Major character in issue Major )
Consts for a later feature. The available importance types.
type Issue ¶
type Issue struct { ID IssueID PublicationDate time.Time `sql:",notnull"` SaleDate time.Time `sql:",notnull"` // @TODO: add an index. IsVariant bool `sql:",notnull"` MonthUncertain bool `sql:",notnull"` Format Format `sql:",notnull"` VendorPublisher string `sql:",notnull"` VendorSeriesName string `sql:",notnull"` VendorSeriesNumber string `sql:",notnull"` // IsReprint means the issue is a full reprint with no original story. (So something like Classic X-Men 7 would not count). IsReprint bool `sql:"default:false,notnull"` VendorType VendorType `sql:",notnull,unique:uix_vendor_type_vendor_id,type:smallint"` VendorID string `sql:",notnull,unique:uix_vendor_type_vendor_id"` CreatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
Issue is an issue with details about its publication and on sale dates.
type IssueCountRank ¶
type IssueCountRank uint
IssueCountRankID is the ranking for the number of issues for a character.
type IssueCriteria ¶
type IssueCriteria struct { Ids []IssueID VendorIds []string VendorType VendorType Formats []Format Limit int Offset int }
IssueCriteria for querying issues.
type IssueRepository ¶
type IssueRepository interface { Create(issue *Issue) error CreateAll(issues []*Issue) error Update(issue *Issue) error FindByVendorID(vendorID string) (*Issue, error) FindAll(c IssueCriteria) ([]*Issue, error) }
IssueRepository is the repository interface for issues.
func NewPGIssueRepository ¶
func NewPGIssueRepository(db *pg.DB) IssueRepository
NewPGIssueRepository creates a new issue repository for the postgres implementation.
type IssueService ¶
type IssueService struct {
// contains filtered or unexported fields
}
IssueService is the service for issues.
func (*IssueService) Create ¶
func (s *IssueService) Create(i *Issue) error
Create creates an issue.
func (*IssueService) CreateP ¶
func (s *IssueService) CreateP(vendorID, vendorPublisher, vendorSeriesName, vendorSeriesNumber string, pubDate, saleDate time.Time, isVariant, isMonthUncertain, isReprint bool, format Format) error
CreateP Creates an issue from the parameters.
func (*IssueService) Issues ¶
func (s *IssueService) Issues(ids []IssueID, limit, offset int) ([]*Issue, error)
Issues gets all the issues by their IDs. A `limit` of `0` means no limit.
func (*IssueService) IssuesByVendor ¶
func (s *IssueService) IssuesByVendor(ids []string, vendorType VendorType, limit, offset int) ([]*Issue, error)
IssuesByVendor gets all the issues by the vendor IDs and vendor type. A limit of `0` means no limit.
type IssueServicer ¶
type IssueServicer interface { // Issues gets issues by their IDs. Issues(ids []IssueID, limit, offset int) ([]*Issue, error) // IssuesByVendor gets issues by their vendor IDs and vendor types. IssuesByVendor(vendorIds []string, vendorType VendorType, limit, offset int) ([]*Issue, error) // Creates an issue. Create(issue *Issue) error // CreateP ceates an issue from parameters. CreateP( vendorID, vendorPublisher, vendorSeriesName, vendorSeriesNumber string, pubDate, saleDate time.Time, isVariant, isMonthUncertain, isReprint bool, format Format) error }
IssueServicer is the service interface for issues.
func NewIssueService ¶
func NewIssueService(container *PGRepositoryContainer) IssueServicer
NewIssueService creates a new issue service from the repository container.
type PGAppearancesByYearsRepository ¶
type PGAppearancesByYearsRepository struct {
// contains filtered or unexported fields
}
PGAppearancesByYearsRepository is the postgres implementation for the appearances per year repository.
func NewPGAppearancesPerYearRepository ¶
func NewPGAppearancesPerYearRepository(db *pg.DB) *PGAppearancesByYearsRepository
NewPGAppearancesPerYearRepository creates the new appearances by year repository for postgres.
func (*PGAppearancesByYearsRepository) Alternate ¶
func (r *PGAppearancesByYearsRepository) Alternate(slug CharacterSlug) (AppearancesByYears, error)
Alternate gets a character's alternate appearances per year. Yes to alternate realities.
func (*PGAppearancesByYearsRepository) Both ¶
func (r *PGAppearancesByYearsRepository) Both(slug CharacterSlug) (AppearancesByYears, error)
Both gets all of a character's appearances per year, which includes its main and alternate counterparts in one struct. (different from List)
func (*PGAppearancesByYearsRepository) List ¶
func (r *PGAppearancesByYearsRepository) List(slugs ...CharacterSlug) ([]AppearancesByYears, error)
List gets a slice of a character's main and alternate appearances. This isn't very efficient for multiple characters so you should use the Redis repo instead.
func (*PGAppearancesByYearsRepository) Main ¶
func (r *PGAppearancesByYearsRepository) Main(slug CharacterSlug) (AppearancesByYears, error)
Main gets a character's main appearances per year. No alternate realities.
type PGCharacterIssueRepository ¶
type PGCharacterIssueRepository struct {
// contains filtered or unexported fields
}
PGCharacterIssueRepository is the postgres implementation for the character issue repository.
func (*PGCharacterIssueRepository) Create ¶
func (r *PGCharacterIssueRepository) Create(ci *CharacterIssue) error
Create creates a character issue.
func (*PGCharacterIssueRepository) CreateAll ¶
func (r *PGCharacterIssueRepository) CreateAll(issues []*CharacterIssue) error
CreateAll creates the issues in the slice.
func (*PGCharacterIssueRepository) FindOneBy ¶
func (r *PGCharacterIssueRepository) FindOneBy(characterID CharacterID, issueID IssueID) (*CharacterIssue, error)
FindOneBy finds a character issue by the params.
func (*PGCharacterIssueRepository) InsertFast ¶
func (r *PGCharacterIssueRepository) InsertFast(issues []*CharacterIssue) error
InsertFast creates all the issues in the db ... but NOTE it does not generate the autoincremented ID's into the models of the slice. :( TODO: Find out why ORM can't do this?!?!
type PGCharacterRepository ¶
type PGCharacterRepository struct {
// contains filtered or unexported fields
}
PGCharacterRepository is the postgres implementation for the character repository.
func (*PGCharacterRepository) Create ¶
func (r *PGCharacterRepository) Create(c *Character) error
Create creates a character.
func (*PGCharacterRepository) FindAll ¶
func (r *PGCharacterRepository) FindAll(cr CharacterCriteria) ([]*Character, error)
FindAll finds characters by the criteria.
func (*PGCharacterRepository) FindBySlug ¶
func (r *PGCharacterRepository) FindBySlug(slug CharacterSlug, includeIsDisabled bool) (*Character, error)
FindBySlug finds a character by its slug. `includeIsDisabled` means to also include disabled characters in the find.
func (*PGCharacterRepository) Remove ¶
func (r *PGCharacterRepository) Remove(id CharacterID) error
Remove removes a character by its ID.
func (*PGCharacterRepository) Total ¶
func (r *PGCharacterRepository) Total(cr CharacterCriteria) (int64, error)
Total gets total number of characters based on the criteria.
func (*PGCharacterRepository) Update ¶
func (r *PGCharacterRepository) Update(c *Character) error
Update updates a character.
func (*PGCharacterRepository) UpdateAll ¶
func (r *PGCharacterRepository) UpdateAll(characters []*Character) error
UpdateAll updates all the characters in the slice.
type PGCharacterSourceRepository ¶
type PGCharacterSourceRepository struct {
// contains filtered or unexported fields
}
PGCharacterSourceRepository is the postgres implementation for the character source repository.
func (*PGCharacterSourceRepository) Create ¶
func (r *PGCharacterSourceRepository) Create(s *CharacterSource) error
Create creates a character source.
func (*PGCharacterSourceRepository) FindAll ¶
func (r *PGCharacterSourceRepository) FindAll(cr CharacterSourceCriteria) ([]*CharacterSource, error)
FindAll finds all the character sources for the criteria.
func (*PGCharacterSourceRepository) Raw ¶
func (r *PGCharacterSourceRepository) Raw(query string, params ...interface{}) error
Raw performs a raw query on the character source. Not ideal but fine for now.
func (*PGCharacterSourceRepository) Remove ¶
func (r *PGCharacterSourceRepository) Remove(id CharacterSourceID) error
Remove removes a character source by its ID.
func (*PGCharacterSourceRepository) Update ¶
func (r *PGCharacterSourceRepository) Update(s *CharacterSource) error
Update updates a character source...
type PGCharacterSyncLogRepository ¶
type PGCharacterSyncLogRepository struct {
// contains filtered or unexported fields
}
PGCharacterSyncLogRepository is the postgres implementation for the character sync log repository.
func (*PGCharacterSyncLogRepository) Create ¶
func (r *PGCharacterSyncLogRepository) Create(s *CharacterSyncLog) error
Create creates a new character sync log.
func (*PGCharacterSyncLogRepository) FindAllByCharacterID ¶
func (r *PGCharacterSyncLogRepository) FindAllByCharacterID(id CharacterID) ([]*CharacterSyncLog, error)
FindAllByCharacterID gets all the sync logs by the character ID.
func (*PGCharacterSyncLogRepository) FindByID ¶
func (r *PGCharacterSyncLogRepository) FindByID(id CharacterSyncLogID) (*CharacterSyncLog, error)
FindByID finds a character sync log by the id.
func (*PGCharacterSyncLogRepository) Update ¶
func (r *PGCharacterSyncLogRepository) Update(l *CharacterSyncLog) error
Update updates a sync log.
type PGIssueRepository ¶
type PGIssueRepository struct {
// contains filtered or unexported fields
}
PGIssueRepository is the postgres implementation for the issue repository.
func (*PGIssueRepository) Create ¶
func (r *PGIssueRepository) Create(issue *Issue) error
Create creates an issue.
func (*PGIssueRepository) CreateAll ¶
func (r *PGIssueRepository) CreateAll(issues []*Issue) error
CreateAll creates all the issue in the slice.
func (*PGIssueRepository) FindAll ¶
func (r *PGIssueRepository) FindAll(cr IssueCriteria) ([]*Issue, error)
FindAll finds all the issues from the criteria.
func (*PGIssueRepository) FindByVendorID ¶
func (r *PGIssueRepository) FindByVendorID(vendorID string) (*Issue, error)
FindByVendorID finds the issues with the specified vendor IDs.
func (*PGIssueRepository) Update ¶
func (r *PGIssueRepository) Update(issue *Issue) error
Update updates an issue.
type PGPopularRepository ¶
type PGPopularRepository struct {
// contains filtered or unexported fields
}
PGPopularRepository is the postgres implementation for the popular character repository.
func (*PGPopularRepository) All ¶
func (r *PGPopularRepository) All(cr PopularCriteria) ([]*RankedCharacter, error)
All returns all the popular characters for DC and Marvel.
func (*PGPopularRepository) DC ¶
func (r *PGPopularRepository) DC(cr PopularCriteria) ([]*RankedCharacter, error)
DC gets the popular characters for DC characters only. The rank will be adjusted for DC.
func (*PGPopularRepository) Marvel ¶
func (r *PGPopularRepository) Marvel(cr PopularCriteria) ([]*RankedCharacter, error)
Marvel gets the popular characters for Marvel characters only. The rank will be adjusted for Marvel.
type PGPublisherRepository ¶
type PGPublisherRepository struct {
// contains filtered or unexported fields
}
PGPublisherRepository is the postgres implementation for the publisher repository.
func (*PGPublisherRepository) FindBySlug ¶
func (r *PGPublisherRepository) FindBySlug(slug PublisherSlug) (*Publisher, error)
FindBySlug gets a publisher by its slug.
type PGRepositoryContainer ¶
type PGRepositoryContainer struct {
// contains filtered or unexported fields
}
PGRepositoryContainer is the container for all the postgres repositories.
func NewPGRepositoryContainer ¶
func NewPGRepositoryContainer(db *pg.DB) *PGRepositoryContainer
NewPGRepositoryContainer creates the new postgres repository container.
func (*PGRepositoryContainer) AppearancesByYearsRepository ¶
func (c *PGRepositoryContainer) AppearancesByYearsRepository() *PGAppearancesByYearsRepository
AppearancesByYearsRepository gets the appearances per year repository.
func (*PGRepositoryContainer) CharacterIssueRepository ¶
func (c *PGRepositoryContainer) CharacterIssueRepository() CharacterIssueRepository
CharacterIssueRepository gets the character issue repository.
func (*PGRepositoryContainer) CharacterRepository ¶
func (c *PGRepositoryContainer) CharacterRepository() CharacterRepository
CharacterRepository gets the character repository.
func (*PGRepositoryContainer) CharacterSourceRepository ¶
func (c *PGRepositoryContainer) CharacterSourceRepository() CharacterSourceRepository
CharacterSourceRepository gets the character source repository.
func (*PGRepositoryContainer) CharacterSyncLogRepository ¶
func (c *PGRepositoryContainer) CharacterSyncLogRepository() CharacterSyncLogRepository
CharacterSyncLogRepository gets the character sync log repository.
func (*PGRepositoryContainer) IssueRepository ¶
func (c *PGRepositoryContainer) IssueRepository() IssueRepository
IssueRepository gets the issue repository.
func (*PGRepositoryContainer) PublisherRepository ¶
func (c *PGRepositoryContainer) PublisherRepository() PublisherRepository
PublisherRepository gets the publisher repository.
func (*PGRepositoryContainer) StatsRepository ¶
func (c *PGRepositoryContainer) StatsRepository() StatsRepository
StatsRepository gets the stats repository.
type PGStatsRepository ¶
type PGStatsRepository struct {
// contains filtered or unexported fields
}
PGStatsRepository is the postgres implementation for the stats repository.
func (*PGStatsRepository) Stats ¶
func (r *PGStatsRepository) Stats() (Stats, error)
Stats gets stats for the comic repository.
type PopularCriteria ¶
type PopularCriteria struct { AppearanceType AppearanceType SortBy PopularSortCriteria Limit int Offset int }
PopularCriteria is for querying ranked and popular characters.
type PopularRepository ¶
type PopularRepository interface { All(cr PopularCriteria) ([]*RankedCharacter, error) DC(cr PopularCriteria) ([]*RankedCharacter, error) Marvel(cr PopularCriteria) ([]*RankedCharacter, error) }
PopularRepository is the repository interface for popular character rankings.
func NewPGPopularRepositoryWithCache ¶
func NewPGPopularRepositoryWithCache(db *pg.DB, r *redis.Client) PopularRepository
NewPGPopularRepositoryWithCache creates the new popular characters repository for postgres and the redis cache for appearances.
type PopularSortCriteria ¶
type PopularSortCriteria string
PopularSortCriteria is criteria for sorting popular characters.
const ( // MostIssues sorts by the most issues for a character. MostIssues PopularSortCriteria = "issue_count" // AverageIssuesPerYear sorts by the highest average issues per year for each character. AverageIssuesPerYear = "average_rank" )
type Publisher ¶
type Publisher struct { ID PublisherID `json:"-"` Name string `json:"name" sql:",notnull"` Slug PublisherSlug `json:"slug" sql:",notnull,unique:uix_publisher_slug"` CreatedAt time.Time `json:"-" sql:",notnull,default:NOW()"` UpdatedAt time.Time `sql:",notnull,default:NOW()" json:"-"` // contains filtered or unexported fields }
Publisher is a publisher is an entity that publishes comics and characters.
type PublisherRepository ¶
type PublisherRepository interface {
FindBySlug(slug PublisherSlug) (*Publisher, error)
}
PublisherRepository is the repository interface for publishers.
func NewPGPublisherRepository ¶
func NewPGPublisherRepository(db *pg.DB) PublisherRepository
NewPGPublisherRepository creates a new publisher repository for the postgres implementation.
type PublisherService ¶
type PublisherService struct {
// contains filtered or unexported fields
}
PublisherService is the service for publishers.
func (*PublisherService) Publisher ¶
func (s *PublisherService) Publisher(slug PublisherSlug) (*Publisher, error)
Publisher gets a publisher by its slug.
type PublisherServicer ¶
type PublisherServicer interface { // Publisher gets a publisher by its slug. Publisher(slug PublisherSlug) (*Publisher, error) }
PublisherServicer is the service interface for publishers.
func NewPublisherService ¶
func NewPublisherService(container *PGRepositoryContainer) PublisherServicer
NewPublisherService creates a new publisher service
type PublisherSlug ¶
type PublisherSlug string
PublisherSlug is the unique string identifier for the publisher.
type RankedCharacter ¶
type RankedCharacter struct { ID CharacterID `json:"-"` Publisher Publisher `json:"publisher"` PublisherID PublisherID `json:"-"` AvgRankID AvgIssuesPerYearRank `json:"average_issues_per_year_rank"` AvgRank float64 `json:"average_issues_per_year"` IssueCountRankID IssueCountRank `json:"issue_count_rank"` IssueCount uint `json:"issue_count"` Name string `json:"name"` OtherName string `json:"other_name"` Description string `json:"description"` Image string `json:"image"` Slug CharacterSlug `json:"slug"` VendorImage string `json:"vendor_image"` VendorURL string `json:"vendor_url"` VendorDescription string `json:"vendor_description"` Appearances []AppearancesByYears `json:"appearances"` }
RankedCharacter represents a character who has its rank and issue count accounted for with its appearances attached..
func (*RankedCharacter) MarshalJSON ¶
func (c *RankedCharacter) MarshalJSON() ([]byte, error)
MarshalJSON overrides the image and vendor image for the CDN url.
type RankedService ¶
type RankedService struct {
// contains filtered or unexported fields
}
RankedService is the service for getting ranked and popular characters.
func (*RankedService) AllPopular ¶
func (s *RankedService) AllPopular(cr PopularCriteria) ([]*RankedCharacter, error)
AllPopular gets the most popular characters per year ordered by either issue count or average appearances per year.
func (*RankedService) DCPopular ¶
func (s *RankedService) DCPopular(cr PopularCriteria) ([]*RankedCharacter, error)
DCPopular gets DC's most popular characters per year.
func (*RankedService) MarvelPopular ¶
func (s *RankedService) MarvelPopular(cr PopularCriteria) ([]*RankedCharacter, error)
MarvelPopular gets Marvel's most popular characters per year ordered by either issue count o or average appearances per year.
type RankedServicer ¶
type RankedServicer interface { AllPopular(cr PopularCriteria) ([]*RankedCharacter, error) DCPopular(cr PopularCriteria) ([]*RankedCharacter, error) MarvelPopular(cr PopularCriteria) ([]*RankedCharacter, error) }
RankedServicer is the interface for getting ranked and popular characters.
func NewRankedService ¶
func NewRankedService(repository PopularRepository) RankedServicer
NewRankedService creates a new service for ranked characters.
type RedisAppearancesByYearsRepository ¶
type RedisAppearancesByYearsRepository struct {
// contains filtered or unexported fields
}
RedisAppearancesByYearsRepository is the Redis implementation for appearances per year repository.
func NewRedisAppearancesPerYearRepository ¶
func NewRedisAppearancesPerYearRepository(client *redis.Client) *RedisAppearancesByYearsRepository
NewRedisAppearancesPerYearRepository creates the redis yearly appearances repository.
func (*RedisAppearancesByYearsRepository) Alternate ¶
func (r *RedisAppearancesByYearsRepository) Alternate(slug CharacterSlug) (AppearancesByYears, error)
Alternate gets a character's alternate appearances per year. Yes alternate realities.
func (*RedisAppearancesByYearsRepository) Both ¶
func (r *RedisAppearancesByYearsRepository) Both(slug CharacterSlug) (AppearancesByYears, error)
Both gets all of a character's appearances per year, which includes its main and alternate counterparts in one struct. (different from List)
func (*RedisAppearancesByYearsRepository) List ¶
func (r *RedisAppearancesByYearsRepository) List(slugs ...CharacterSlug) ([]AppearancesByYears, error)
List returns a slice of appearances per year for the given characters' slugs main and alternate appearances.
func (*RedisAppearancesByYearsRepository) ListMap ¶
func (r *RedisAppearancesByYearsRepository) ListMap(slugs ...CharacterSlug) (map[CharacterSlug][]AppearancesByYears, error)
ListMap returns a map of appearances per year for the given characters' slugs main and alternate appearances.
func (*RedisAppearancesByYearsRepository) Main ¶
func (r *RedisAppearancesByYearsRepository) Main(slug CharacterSlug) (AppearancesByYears, error)
Main gets a character's main appearances per year. No alternate realities.
func (*RedisAppearancesByYearsRepository) Set ¶
func (r *RedisAppearancesByYearsRepository) Set(character AppearancesByYears) error
Set sets the character's info like this: HMSET KEY name "character.Name" Sets the character's appearances like this: ZADDNX KEY:yearly 1 "1979" 2 "1980"
type Stats ¶
type Stats struct { TotalCharacters int `json:"total_characters"` TotalAppearances int `json:"total_appearances"` MinYear int `json:"min_year"` MaxYear int `json:"max_year"` TotalIssues int `json:"total_issues"` }
Stats represents general stats about the db.
type StatsRepository ¶
StatsRepository is the repository interface for general stats about the db.
func NewPGStatsRepository ¶
func NewPGStatsRepository(db *pg.DB) StatsRepository
NewPGStatsRepository creates a new stats repository for the postgres implementation.
type Syncer ¶
type Syncer interface { // Syncs appearances from postgres to redis. Returns the number of issues synced and an error if any. Sync(slug CharacterSlug) (int, error) }
Syncer is the interface for syncing yearly appearances from persistence to a cache.
func NewAppearancesSyncer ¶
func NewAppearancesSyncer(r *PGRepositoryContainer, w *RedisAppearancesByYearsRepository) Syncer
NewAppearancesSyncer returns a new appearances syncer
func NewAppearancesSyncerRW ¶
func NewAppearancesSyncerRW(r AppearancesByYearsRepository, w AppearancesByYearsWriter) Syncer
type TrendingCriteria ¶
type TrendingCriteria struct { PublisherID PublisherID Limit int Offset int }
TrendingCriteria is for querying characters who are trending.
type VendorType ¶
type VendorType int
VendorType is type of vendor from an external source for an issue.
const ( VendorTypeCb VendorType = iota VendorTypeMarvel VendorTypeDC )
Vendor types for the characters and character sources.
type YearlyAggregate ¶
YearlyAggregate is the aggregated year and count of an appearance for that year.