Add WithNonactiveKillSwitches field to GetKillSwitchOverviewRequest
This will be used by the extension to only get active kill switches.
Change-Id: Ibe7ad4cdb74ab7b385f3d18b70e74da6b834375c
diff --git a/internal/db/kill_switch.go b/internal/db/kill_switch.go
index 3c85f2b..6693000 100644
--- a/internal/db/kill_switch.go
+++ b/internal/db/kill_switch.go
@@ -63,10 +63,14 @@
return &k, nil
}
-func ListKillSwitches(db *sql.DB, ctx context.Context) ([]*pb.KillSwitch, error) {
+func ListKillSwitches(db *sql.DB, ctx context.Context, withNonactiveKillSwitches bool) ([]*pb.KillSwitch, error) {
var rows *sql.Rows
var err error
- rows, err = db.QueryContext(ctx, "SELECT kswitch_id, feat_id, min_version, max_version, active FROM KillSwitch")
+ if withNonactiveKillSwitches {
+ rows, err = db.QueryContext(ctx, "SELECT kswitch_id, feat_id, min_version, max_version, active FROM KillSwitch")
+ } else {
+ rows, err = db.QueryContext(ctx, "SELECT kswitch_id, feat_id, min_version, max_version, active FROM KillSwitch WHERE active <> 0")
+ }
if err != nil {
return nil, fmt.Errorf("ListKillSwitches: ", err)
}