Skip to content

Commit

Permalink
fix invested amounts for campaign detail
Browse files Browse the repository at this point in the history
  • Loading branch information
ogous committed Jan 23, 2025
1 parent c35b0a3 commit d9cc1b1
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 60 deletions.
96 changes: 48 additions & 48 deletions cmd/graphql.ethereum/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/graphql.ethereum/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ type Campaign {
"""
Represents investment results bytes8 ids to amounts.
"""
investmentAmounts: [InvestmentAmounts!]
investmentAmounts: [InvestmentAmounts]!
}

type InvestmentAmounts {
Expand Down
4 changes: 2 additions & 2 deletions cmd/graphql.ethereum/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions lib/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ import (

type (
Campaign struct {
ID string `gorm:"primaryKey"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
Content CampaignContent `json:"content"`
TotalVolume int `json:"totalVolume"`
Winner string `json:"winner"`
ID string `gorm:"primaryKey"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
Content CampaignContent `json:"content"`
TotalVolume int `json:"totalVolume"`
Winner string `json:"winner"`
InvestmentAmounts InvestmentAmountsList `json:"investmentAmounts" gorm:"type:jsonb"`
}

InvestmentAmounts struct {
Id string `json:"id"`
Amount int `json:"amount"`
}

InvestmentAmountsList []*InvestmentAmounts

Outcome struct {
// Name of this campaign.
Name string `json:"name"`
Expand Down Expand Up @@ -90,9 +93,6 @@ type (

// Web url
Web *string `json:"web"`

// Represents current investment amounts.
InvestmentAmounts []InvestmentAmounts `json:"investmentAmounts"`
}

// Wallet of the creator of a campaign.
Expand Down Expand Up @@ -167,6 +167,22 @@ func (content *CampaignContent) Scan(value interface{}) error {
return JSONUnmarshal(value, content)
}

func (ai InvestmentAmounts) Value() (driver.Value, error) {
return JSONMarshal(ai)
}

func (ai InvestmentAmounts) Scan(value interface{}) error {
return JSONUnmarshal(value, ai)
}

func (ai InvestmentAmountsList) Value() (driver.Value, error) {
return JSONMarshal(ai)
}

func (ai *InvestmentAmountsList) Scan(value interface{}) error {
return JSONUnmarshal(value, ai)
}

type Frontpage struct {
Campaigns []Campaign `json:"campaigns"`
}

0 comments on commit d9cc1b1

Please sign in to comment.