models

package
v1.3.35 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

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

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

func (*Event) BeforeUpdate

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

func (*Event) ToHeadline

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

func (*Event) Validate

func (e *Event) Validate() error

type EventsDB

type EventsDB struct {
	Conn *gorm.DB
}

func NewEventsDB

func NewEventsDB(db *gorm.DB) *EventsDB

func (*EventsDB) Create

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

func (*EventsDB) FindAllUntilDate

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

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

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

type News

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" 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)
	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

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

func (*News) GenerateHash

func (n *News) GenerateHash()

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

func (*News) ToHeadline

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

func (*News) Validate

func (n *News) Validate() error

type NewsDB

type NewsDB struct {
	Conn *gorm.DB
}

func NewNewsDB

func NewNewsDB(db *gorm.DB) *NewsDB

func (*NewsDB) Create

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

func (*NewsDB) FindAllByHashes

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

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

func (*NewsDB) FindAllUntilDate

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

FindAllUntilDate finds all news until the provided published date.

func (*NewsDB) Update

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