archivist

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archivist

type Archivist struct {
	Entities *entities
	// contains filtered or unexported fields
}

Archivist is responsible for storing and retrieving data from the database.

func NewArchivist

func NewArchivist(dsn string) (*Archivist, error)

NewArchivist creates a new Archivist with provided DSN to connect to database.

DSN is a string in the format of: "user=gorm password=gorm dbname=gorm port=9920 sslmode=disable".

type Event added in v1.5.0

type Event struct {
	ID           uuid.UUID                     `gorm:"primaryKey;type:uuid;not null;" json:"id"` // ID of the event (UUID)
	ChannelID    string                        `gorm:"size:64" json:"channel_id"`                // ID of the channel (chat ID in Telegram)
	ProviderName string                        `gorm:"size:64" json:"provider_name"`             // Name of the provider (e.g. "mql5")
	Title        string                        `gorm:"size:256" json:"title"`                    // Event title
	DateTime     time.Time                     `gorm:"not null" json:"date_time"`                // Event date and time
	Country      ecal.EconomicCalendarCountry  `gorm:"size:32" json:"country"`                   // Country of the event
	Currency     ecal.EconomicCalendarCurrency `gorm:"size:10" json:"currency"`                  // Currency impacted by the event
	Impact       ecal.EconomicCalendarImpact   `gorm:"size:10" json:"impact"`                    // Impact of the event on the market
	Actual       string                        `gorm:"size:64" json:"actual"`                    // Actual value of the event (if available)
	Forecast     string                        `gorm:"size:64" json:"forecast"`                  // Forecasted value of the event (if available)
	Previous     string                        `gorm:"size:64" json:"previous"`                  // Previous value of the event (if available)
	CreatedAt    time.Time                     `gorm:"default:CURRENT_TIMESTAMP" json:"created_at,omitempty"`
	UpdatedAt    time.Time                     `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at,omitempty"`
}

func (*Event) BeforeCreate added in v1.5.0

func (e *Event) BeforeCreate(_ *gorm.DB) error

func (*Event) BeforeUpdate added in v1.5.0

func (e *Event) BeforeUpdate(_ *gorm.DB) error

func (*Event) ToHeadline added in v1.5.0

func (e *Event) ToHeadline() *composer.Headline

func (*Event) Validate added in v1.5.0

func (e *Event) Validate() error

type EventsDB added in v1.5.0

type EventsDB struct {
	Conn *gorm.DB
}

func NewEventsDB added in v1.5.0

func NewEventsDB(db *gorm.DB) *EventsDB

func (*EventsDB) Create added in v1.5.0

func (edb *EventsDB) Create(ctx context.Context, e []*Event) error

func (*EventsDB) FindAllUntilDate added in v1.5.0

func (edb *EventsDB) FindAllUntilDate(ctx context.Context, until time.Time) ([]*Event, error)

FindAllUntilDate finds all events between time.Now until the provided date.

func (*EventsDB) FindRecentEventsWithoutValue added in v1.5.0

func (edb *EventsDB) FindRecentEventsWithoutValue(ctx context.Context) ([]*Event, error)

FindRecentEventsWithoutValue finds events without Event.Actual value from the start of the day. Also, it filters out events with Event.Impact = None and Event.Impact = Holiday (e.g. no impact events).

func (*EventsDB) Update added in v1.5.0

func (edb *EventsDB) Update(ctx context.Context, e *Event) error

type News added in v1.5.0

type News struct {
	ID            uuid.UUID      `gorm:"primaryKey;type:uuid;not null;" json:"id"`  // ID of the news (UUID)
	Hash          string         `gorm:"size:32;uniqueIndex;not null;" json:"hash"` // MD5 Hash of the news (URL + title + description + date)
	ChannelID     string         `gorm:"size:64" json:"channel_id"`                 // ID of the channel (chat ID in Telegram)
	PublicationID string         `gorm:"size:64" json:"publication_id"`             // ID of the publication (message ID in Telegram)
	ProviderName  string         `gorm:"size:64" json:"provider_name"`              // Name of the provider (e.g. "Reuters")
	URL           string         `gorm:"size:512;uniqueIndex;not null;" json:"url"` // URL of the original news
	OriginalTitle string         `gorm:"size:512" json:"original_title"`            // Original News title
	OriginalDesc  string         `gorm:"size:1024" json:"original_desc"`            // Original News description
	ComposedText  string         `gorm:"size:512" json:"composed_text"`             // Composed text
	MetaData      datatypes.JSON `gorm:"" json:"meta_data"`                         // Meta data (tickers, markets, hashtags, etc.)
	IsSuspicious  bool           `gorm:"default:false" json:"is_suspicious"`        // Is the news suspicious (contains keywords that should be checked by human before publishing)
	IsFiltered    bool           `gorm:"default:false" json:"is_filtered"`          // Is the news filtered out by others service (e.g. Composer.Filter)
	PublishedAt   time.Time      `gorm:"default:null" json:"published_at"`          // Composed News publication date
	OriginalDate  time.Time      `gorm:"not null" json:"original_date"`             // Original News date
	CreatedAt     time.Time      `gorm:"default:CURRENT_TIMESTAMP" json:"created_at,omitempty"`
	UpdatedAt     time.Time      `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at,omitempty"`
}

func (*News) BeforeCreate added in v1.5.0

func (n *News) BeforeCreate(*gorm.DB) error

func (*News) GenerateHash added in v1.5.0

func (n *News) GenerateHash()

GenerateHash generates the hash of the news (title + description).

func (*News) ToHeadline added in v1.5.0

func (n *News) ToHeadline() *composer.Headline

func (*News) Validate added in v1.5.0

func (n *News) Validate() error

type NewsDB added in v1.5.0

type NewsDB struct {
	Conn *gorm.DB
}

func NewNewsDB added in v1.5.0

func NewNewsDB(db *gorm.DB) *NewsDB

func (*NewsDB) Create added in v1.5.0

func (db *NewsDB) Create(ctx context.Context, n []*News) error

func (*NewsDB) FindAllByHashes added in v1.5.0

func (db *NewsDB) FindAllByHashes(ctx context.Context, hashes []string) ([]*News, error)

FindAllByHashes finds news by its hash (URL + title + description + date).

func (*NewsDB) FindAllByUrls added in v1.5.0

func (db *NewsDB) FindAllByUrls(ctx context.Context, urls []string) ([]*News, error)

FindAllByUrls finds news by its URL.

func (*NewsDB) FindAllUntilDate added in v1.5.0

func (db *NewsDB) FindAllUntilDate(ctx context.Context, until time.Time) ([]*News, error)

FindAllUntilDate finds all news until the provided published date.

func (*NewsDB) Update added in v1.5.0

func (db *NewsDB) Update(ctx context.Context, n *News) error

Jump to

Keyboard shortcuts

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