From 16d9c2e345d7cc8c381e127dc37ed37689c6a4e5 Mon Sep 17 00:00:00 2001 From: Zagarazhi Date: Tue, 6 Aug 2024 15:02:36 +0400 Subject: [PATCH 1/8] add slug to research pairs --- shared/research.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/research.go b/shared/research.go index b933484..0a95096 100644 --- a/shared/research.go +++ b/shared/research.go @@ -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 { @@ -398,6 +398,8 @@ type ResearchPair struct { QuoteAssetId uint64 `json:"quoteAssetId" gorm:"uniqueIndex:pair_idx"` BaseAssetType string `json:"baseAssetType" gorm:"uniqueIndex:pair_idx"` QuoteAssetType string `json:"qouteAssetType" gorm:"uniqueIndex:pair_idx"` + BaseAssetSlug string `json:"baseAssetSlug"` + QuoteAssetSlug string `json:"quoteAssetSlug"` MarketType string `json:"marketType"` ExchangeID uint64 `gorm:"uniqueIndex:pair_idx"` Exchange Exchange `gorm:"foreignKey:ExchangeID;references:ID"` From 4771a40d21be0563f4ea99c8f3941d3cf1ebc757 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Aug 2024 17:17:50 +0500 Subject: [PATCH 2/8] remove type from historic tvl all --- .gitignore | 4 ++++ shared/research.go | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9c738e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea/ +.vscode/ + +.DS_Store diff --git a/shared/research.go b/shared/research.go index 0a95096..0e6f136 100644 --- a/shared/research.go +++ b/shared/research.go @@ -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 } From 939b5108cc99a9b351a36c18cc38694f3a753a12 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Aug 2024 18:07:23 +0500 Subject: [PATCH 3/8] fix user referral field --- shared/toscale.go | 76 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/shared/toscale.go b/shared/toscale.go index c6c65fa..aadd9dc 100644 --- a/shared/toscale.go +++ b/shared/toscale.go @@ -1,29 +1,29 @@ package shared 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 + Avatar string + Password string + CreatedAt uint64 `gorm:"column:createdAt"` + Referral 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"` } func (User) TableName() string { @@ -31,20 +31,20 @@ func (User) TableName() string { } type AdminPermission struct { - ID uint64 `gorm:"primaryKey"` - UserId uint64 - User User `gorm:"foreignKey:ID;references:UserId"` - IsAvaliableTools bool - IsAvaliableTerminals bool - IsAvaliableUsers bool - IsAvaliableBackendTesting bool - IsAvaliableDocumentation bool - IsAvaliableInsights bool - IsAvaliableBalancer bool - IsAvaliableNews bool - IsAvaliableTwitter bool - IsAvaliableForex bool - IsAvaliableLanguages bool + ID uint64 `gorm:"primaryKey"` + UserId uint64 + User User `gorm:"foreignKey:ID;references:UserId"` + IsAvaliableTools bool + IsAvaliableTerminals bool + IsAvaliableUsers bool + IsAvaliableBackendTesting bool + IsAvaliableDocumentation bool + IsAvaliableInsights bool + IsAvaliableBalancer bool + IsAvaliableNews bool + IsAvaliableTwitter bool + IsAvaliableForex bool + IsAvaliableLanguages bool } type InstalledService struct { @@ -105,4 +105,4 @@ type ApiKey struct { TokensUsedMonth uint64 `gorm:"default:0"` TotalTokensMonth uint64 `gorm:"default:10000"` ExpirityDate uint64 -} \ No newline at end of file +} From eb38d7e95699598c37ae3689ddad3fa6db9546a3 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Aug 2024 18:13:49 +0500 Subject: [PATCH 4/8] fix user newslang field --- shared/toscale.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/toscale.go b/shared/toscale.go index aadd9dc..d5abaa1 100644 --- a/shared/toscale.go +++ b/shared/toscale.go @@ -17,7 +17,7 @@ type User struct { TwoFaEnabled bool `gorm:"column:twoFaEnabled"` LastOnline uint64 `gorm:"column:lastOnline"` Verified bool `gorm:"column:verified"` - NewsLang string `gorm:"column:newsLang"` + NewsLang string `gorm:"column:newslang"` AssetId uint64 `gorm:"column:assetId"` AvaliableMarketplace bool `gorm:"column:avaliableMarketplace"` AvaliablePortfolio bool `gorm:"column:avaliablePortfolio"` From 6af7da97ba352ee0656db9888812205ca8b0f7a2 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Aug 2024 18:23:25 +0500 Subject: [PATCH 5/8] fix user model --- shared/toscale.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/shared/toscale.go b/shared/toscale.go index d5abaa1..e2e90d0 100644 --- a/shared/toscale.go +++ b/shared/toscale.go @@ -1,5 +1,7 @@ package shared +import "database/sql" + type User struct { ID uint64 `gorm:"primaryKey"` Name string @@ -8,22 +10,22 @@ type User struct { Avatar string Password string CreatedAt uint64 `gorm:"column:createdAt"` - Referral uint64 + Referral sql.Null[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"` + 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 { From 7631009d2be78ab2e1ff19679c407ffc16f4ba37 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Aug 2024 23:32:03 +0500 Subject: [PATCH 6/8] add user default role --- shared/toscale.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/toscale.go b/shared/toscale.go index e2e90d0..9ec6af3 100644 --- a/shared/toscale.go +++ b/shared/toscale.go @@ -6,7 +6,7 @@ type User struct { ID uint64 `gorm:"primaryKey"` Name string Email string - Role string + Role string `gorm:"default:user"` Avatar string Password string CreatedAt uint64 `gorm:"column:createdAt"` From e6c9269a75f60493056d66d621b9dcd260c20bfc Mon Sep 17 00:00:00 2001 From: Zagarazhi Date: Thu, 8 Aug 2024 17:13:59 +0400 Subject: [PATCH 7/8] remove hoock --- shared/trade.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/shared/trade.go b/shared/trade.go index e54a651..b7b7e07 100644 --- a/shared/trade.go +++ b/shared/trade.go @@ -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"` @@ -147,4 +126,4 @@ type DexOrganizedTickers struct { BaseVolume float64 `json:"baseVolume"` QuoteVolume float64 `json:"quoteVolume"` CreatedAt uint64 `json:"createdAt" gorm:"autoCreateTime:milli"` -} \ No newline at end of file +} From 0ab80a3280f051f165a70130c82261bcdc75b747 Mon Sep 17 00:00:00 2001 From: Zagarazhi Date: Thu, 8 Aug 2024 17:28:28 +0400 Subject: [PATCH 8/8] temp remove slugs --- shared/research.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared/research.go b/shared/research.go index 0e6f136..9aa85d3 100644 --- a/shared/research.go +++ b/shared/research.go @@ -397,8 +397,6 @@ type ResearchPair struct { QuoteAssetId uint64 `json:"quoteAssetId" gorm:"uniqueIndex:pair_idx"` BaseAssetType string `json:"baseAssetType" gorm:"uniqueIndex:pair_idx"` QuoteAssetType string `json:"qouteAssetType" gorm:"uniqueIndex:pair_idx"` - BaseAssetSlug string `json:"baseAssetSlug"` - QuoteAssetSlug string `json:"quoteAssetSlug"` MarketType string `json:"marketType"` ExchangeID uint64 `gorm:"uniqueIndex:pair_idx"` Exchange Exchange `gorm:"foreignKey:ExchangeID;references:ID"`