Documentation ¶
Index ¶
- type Archivist
- type Event
- type EventsDB
- func (edb *EventsDB) Create(ctx context.Context, e []*Event) error
- func (edb *EventsDB) FindAllUntilDate(ctx context.Context, until time.Time) ([]*Event, error)
- func (edb *EventsDB) FindRecentEventsWithoutValue(ctx context.Context) ([]*Event, error)
- func (edb *EventsDB) Update(ctx context.Context, e *Event) error
- type News
- type NewsDB
- func (db *NewsDB) Create(ctx context.Context, n []*News) error
- func (db *NewsDB) FindAllByHashes(ctx context.Context, hashes []string) ([]*News, error)
- func (db *NewsDB) FindAllByUrls(ctx context.Context, urls []string) ([]*News, error)
- func (db *NewsDB) FindAllUntilDate(ctx context.Context, until time.Time) ([]*News, error)
- func (db *NewsDB) Update(ctx context.Context, n *News) error
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 ¶
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) ToHeadline ¶ added in v1.5.0
type EventsDB ¶ added in v1.5.0
func NewEventsDB ¶ added in v1.5.0
func (*EventsDB) FindAllUntilDate ¶ added in v1.5.0
FindAllUntilDate finds all events between time.Now until the provided date.
func (*EventsDB) FindRecentEventsWithoutValue ¶ added in v1.5.0
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).
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) 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
type NewsDB ¶ added in v1.5.0
func (*NewsDB) FindAllByHashes ¶ added in v1.5.0
FindAllByHashes finds news by its hash (URL + title + description + date).
func (*NewsDB) FindAllByUrls ¶ added in v1.5.0
FindAllByUrls finds news by its URL.
func (*NewsDB) FindAllUntilDate ¶ added in v1.5.0
FindAllUntilDate finds all news until the provided published date.