@@ -13,16 +13,17 @@ import (
13
13
const (
14
14
settingsTable = "settings"
15
15
settingsTableFields = `window_width, window_height, window_x, window_y, single_instance, connect_timeout,
16
- request_timeout, k8s_request_timeout, non_blocking_connection, sort_methods_by_name, max_loop_depth`
16
+ request_timeout, k8s_request_timeout, non_blocking_connection, sort_methods_by_name, max_loop_depth,
17
+ emit_defaults, check_updates`
17
18
)
18
19
19
- // SettingsRepository object capable of interacting with SettingsRepository
20
+ // SettingsRepository object capable of interacting with SettingsRepository.
20
21
type SettingsRepository struct {
21
22
db * database.Database
22
23
ctx context.Context
23
24
}
24
25
25
- // NewSettingsRepository creates a new SettingsRepository
26
+ // NewSettingsRepository creates a new SettingsRepository.
26
27
func NewSettingsRepository (ctx context.Context , db * database.Database ) * SettingsRepository {
27
28
return & SettingsRepository {
28
29
db : db ,
@@ -42,6 +43,8 @@ type settingsDTO struct {
42
43
NonBlockingConnection bool `db:"non_blocking_connection"`
43
44
SortMethodsByName bool `db:"sort_methods_by_name"`
44
45
MaxLoopDepth int `db:"max_loop_depth"`
46
+ EmitDefaults bool `db:"emit_defaults"`
47
+ CheckUpdates bool `db:"check_updates"`
45
48
}
46
49
47
50
func (dto * settingsDTO ) entity () * entity.Settings {
@@ -57,10 +60,12 @@ func (dto *settingsDTO) entity() *entity.Settings {
57
60
NonBlockingConnection : & dto .NonBlockingConnection ,
58
61
SortMethodsByName : & dto .SortMethodsByName ,
59
62
MaxLoopDepth : & dto .MaxLoopDepth ,
63
+ EmitDefaults : & dto .EmitDefaults ,
64
+ CheckUpdates : & dto .CheckUpdates ,
60
65
}
61
66
}
62
67
63
- // Get returns Settings
68
+ // Get returns Settings.
64
69
func (repo * SettingsRepository ) Get () (* entity.Settings , error ) {
65
70
dto := & settingsDTO {}
66
71
@@ -72,11 +77,11 @@ func (repo *SettingsRepository) Get() (*entity.Settings, error) {
72
77
return dto .entity (), nil
73
78
}
74
79
75
- // Update updates Settings
80
+ // Update updates Settings.
76
81
func (repo * SettingsRepository ) Update (in * entity.Settings ) (* entity.Settings , error ) {
77
82
dto := & settingsDTO {}
78
- attrs := make ([]string , 0 , 10 )
79
- mapper := make (map [string ]interface {}, 11 )
83
+ attrs := make ([]string , 0 , 13 )
84
+ mapper := make (map [string ]interface {}, 13 )
80
85
81
86
if in .WindowWidth > 0 {
82
87
attrs = append (attrs , "window_width = :window_width" )
@@ -122,6 +127,14 @@ func (repo *SettingsRepository) Update(in *entity.Settings) (*entity.Settings, e
122
127
attrs = append (attrs , "max_loop_depth = :max_loop_depth" )
123
128
mapper ["max_loop_depth" ] = in .MaxLoopDepth
124
129
}
130
+ if in .EmitDefaults != nil {
131
+ attrs = append (attrs , "emit_defaults = :emit_defaults" )
132
+ mapper ["emit_defaults" ] = in .EmitDefaults
133
+ }
134
+ if in .CheckUpdates != nil {
135
+ attrs = append (attrs , "check_updates = :check_updates" )
136
+ mapper ["check_updates" ] = in .CheckUpdates
137
+ }
125
138
if len (attrs ) == 0 {
126
139
return repo .Get ()
127
140
}
0 commit comments