-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OFF-1457 #7
OFF-1457 #7
Conversation
adapters/flipp/flipp.go
Outdated
customDataInterface := decision.Contents[0].Data.CustomData | ||
customDataMap, ok := customDataInterface.(map[string]interface{}) | ||
var defaultStandardHeight int64 = 2400 | ||
var defaultCompactHeight int64 = 600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use const
for constants and place them at the beginning of the file
adapters/flipp/flipp.go
Outdated
var defaultStandardHeight int64 = 2400 | ||
var defaultCompactHeight int64 = 600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should move this to the top of the file with all the other consts
adapters/flipp/flipp.go
Outdated
if flippExtParams.Options.StartCompact { | ||
if ok { // check if customDataMap exists and startCompact is true | ||
if height, exists := customDataMap["compactHeight"].(int64); exists { | ||
bid.H = height | ||
} else { | ||
bid.H = defaultCompactHeight | ||
} | ||
} else { | ||
bid.H = defaultCompactHeight | ||
} | ||
} else { // startCompact is false | ||
if ok { // customDataMap exists | ||
if height, exists := customDataMap["standardHeight"].(int64); exists { | ||
bid.H = height | ||
} else { | ||
bid.H = defaultStandardHeight | ||
} | ||
} else { | ||
bid.H = defaultStandardHeight | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this a little further by doing
if flippExtParams.Options.StartCompact {
defaultHeight = defaultCompactHeight
} else {
defaultHeight = defaultStandardHeight
}
bid.H = defaultHeight
if ok {
if height, exists := customDataMap[flippExtParams.Options.StartCompact ? "compactHeight" : "standardHeight"].(int64); exists {
bid.H = height
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if height, exists := customDataMap[flippExtParams.Options.StartCompact ? "compactHeight" : "standardHeight"].(int64); exists {
I get an error for the ? operator, saying expected ']', found 'ILLEGAL'syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry 🤦♂️ you can do this instead
if flippExtParams.Options.StartCompact {
defaultHeight = 600 // Default compact height
} else {
defaultHeight = 2400 // Default standard height
}
// Set default height first
bid.H = defaultHeight
if ok { // customDataMap exists
var key string
if flippExtParams.Options.StartCompact {
key = "compactHeight"
} else {
key = "standardHeight"
}
if height, exists := customDataMap[key].(int64); exists {
bid.H = height
}
}
48710ca
to
905b3a5
Compare
No description provided.