Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-core into develop
  • Loading branch information
Maksiomo committed Aug 14, 2024
2 parents ea5d84b + 0ab80a3 commit 47bc0b8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
.vscode/

.DS_Store
5 changes: 2 additions & 3 deletions shared/research.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ type Forex struct {
High float64
Close float64
Date int64
Type string `gorm:"-" json:"type"`
Type string `gorm:"-" json:"type"`
}

type ForexAsset struct {
Expand Down Expand Up @@ -361,9 +361,8 @@ type WatchList struct {
}

type HistoricTvlAll struct {
Timestamp uint64 `gorm:"uniqueIndex:idx_historic_name"`
Name string `gorm:"uniqueIndex:idx_historic_name"`
Type string
Timestamp uint64 `gorm:"uniqueIndex:idx_historic_name"`
TotalUsdLiquidity float64
}

Expand Down
50 changes: 26 additions & 24 deletions shared/toscale.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package shared

import "database/sql"

type User struct {
ID uint64 `gorm:"primaryKey"`
Name string
Email string
Role string
Avatar string
Password string
CreatedAt uint64 `gorm:"column:createdAt"`
Referal uint64
Lang string
EmailConfirmed bool `gorm:"column:emailConfirm"`
TwoFaSecret string `gorm:"column:twoFaSecret"`
ContainerId string `gorm:"column:containerId"`
TaskId string `gorm:"column:taskId"`
TwoFaEnabled bool `gorm:"column:twoFaEnabled"`
LastOnline uint64 `gorm:"column:lastOnline"`
Verified bool `gorm:"column:verified"`
NewsLang string `gorm:"column:newsLang"`
AssetId uint64 `gorm:"column:assetId"`
AvaliableMarketplace bool `gorm:"column:avaliableMarketplace"`
AvaliablePortfolio bool `gorm:"column:avaliablePortfolio"`
AvaliableTerminal bool `gorm:"column:avaliableTerminal"`
AvaliableLending bool `gorm:"column:avaliableLending"`
AvaliableAssist bool `gorm:"column:avaliableAssist"`
ID uint64 `gorm:"primaryKey"`
Name string
Email string
Role string `gorm:"default:user"`
Avatar string
Password string
CreatedAt uint64 `gorm:"column:createdAt"`
Referral sql.Null[uint64]
Lang string
EmailConfirmed bool `gorm:"column:emailConfirm"`
TwoFaSecret string `gorm:"column:twoFaSecret"`
ContainerId sql.NullString `gorm:"column:containerId"`
TaskId sql.NullString `gorm:"column:taskId"`
TwoFaEnabled bool `gorm:"column:twoFaEnabled"`
LastOnline uint64 `gorm:"column:lastOnline"`
Verified bool `gorm:"column:verified"`
NewsLang string `gorm:"column:newslang"`
AssetId sql.Null[uint64] `gorm:"column:assetId"`
AvaliableMarketplace bool `gorm:"column:avaliableMarketplace"`
AvaliablePortfolio bool `gorm:"column:avaliablePortfolio"`
AvaliableTerminal bool `gorm:"column:avaliableTerminal"`
AvaliableLending bool `gorm:"column:avaliableLending"`
AvaliableAssist bool `gorm:"column:avaliableAssist"`
}

func (User) TableName() string {
Expand Down Expand Up @@ -105,4 +107,4 @@ type ApiKey struct {
TokensUsedMonth uint64 `gorm:"default:0"`
TotalTokensMonth uint64 `gorm:"default:10000"`
ExpirityDate uint64
}
}
23 changes: 1 addition & 22 deletions shared/trade.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
package shared

import (
"errors"

"gorm.io/gorm"
)

func (ticker *OrganizedTickers) BeforeCreate(tx *gorm.DB) (err error) {
var existingTicker OrganizedTickers
result := tx.Where("symbol = ? AND exchange = ?", ticker.Symbol, ticker.Exchange).First(&existingTicker)

if result.Error == nil || result.RowsAffected > 0 {
ticker.ID = existingTicker.ID
} else if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return tx.Raw("SELECT nextval('organized_tickers_id_seq')").Scan(&ticker.ID).Error
} else {
return result.Error
}

return nil
}

type OrganizedTickers struct {
ID uint64 `json:"id" gorm:"primaryKey"`
Exchange string `json:"-" gorm:"uniqueIndex:idx_uniq_ticker"`
Expand Down Expand Up @@ -147,4 +126,4 @@ type DexOrganizedTickers struct {
BaseVolume float64 `json:"baseVolume"`
QuoteVolume float64 `json:"quoteVolume"`
CreatedAt uint64 `json:"createdAt" gorm:"autoCreateTime:milli"`
}
}

0 comments on commit 47bc0b8

Please sign in to comment.