Archived
1
0
Fork 0

feat: Add NVIDIA FE (#15)

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2022-07-22 19:34:03 +02:00
commit 991880f1c9
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
4 changed files with 228 additions and 0 deletions

View file

@ -13,6 +13,7 @@ type Config struct {
TelegramConfig `json:"telegram"`
APIConfig `json:"api"`
AmazonConfig `json:"amazon"`
NvidiaFEConfig `json:"nvidia_fe"`
URLs []string `json:"urls"`
IncludeRegex string `json:"include_regex"`
ExcludeRegex string `json:"exclude_regex"`
@ -66,6 +67,14 @@ type AmazonConfig struct {
AffiliateLinks bool `json:"affiliate_links"`
}
// NvidiaFEConfig to store NVIDIA Founders Edition configuration
type NvidiaFEConfig struct {
Locations []string `json:"locations"`
GPUs []string `json:"gpus"`
UserAgent string `json:"user_agent"`
Timeout int `json:"timeout"`
}
// PriceRange to store rules to filter products with price outside of the range
type PriceRange struct {
Model string `json:"model"`
@ -118,6 +127,11 @@ func (c *Config) HasDatabase() bool {
return c.DatabaseConfig.Type != "" && c.DatabaseConfig.DSN != ""
}
// HasNvidiaFE returns true when NVIDIA FE has been configured
func (c *Config) HasNvidiaFE() bool {
return len(c.NvidiaFEConfig.Locations) > 0 && len(c.NvidiaFEConfig.GPUs) > 0
}
// HasAmazon returns true when Amazon has been configured
func (c *Config) HasAmazon() bool {
var hasKeys, hasSearches, hasMarketplaces bool