diff options
author | Jebbs <qjebbs@gmail.com> | 2018-12-06 12:35:30 +0800 |
---|---|---|
committer | fguillot <fred@miniflux.net> | 2018-12-05 20:35:30 -0800 |
commit | 87648490fda1d765fb7b78544b2b01847550c82b (patch) | |
tree | fe57b9c00b0ec311d74af4a55a8db5ee4ce72913 /config | |
parent | 3e392dc3ae7926266f18edbc2a6309cf195cb676 (diff) |
Make configurable the number of days to archive read items
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 6 | ||||
-rw-r--r-- | config/config_test.go | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go index 7ba3a93..99afaef 100644 --- a/config/config.go +++ b/config/config.go @@ -21,6 +21,7 @@ const ( defaultBatchSize = 10 defaultDatabaseMaxConns = 20 defaultDatabaseMinConns = 1 + defaultArchiveReadDays = 60 defaultListenAddr = "127.0.0.1:8080" defaultCertFile = "" defaultKeyFile = "" @@ -224,6 +225,11 @@ func (c *Config) HasSchedulerService() bool { return !getBooleanValue("DISABLE_SCHEDULER_SERVICE") } +// ArchiveReadDays returns the number of days after which marking read items as removed. +func (c *Config) ArchiveReadDays() int { + return getIntValue("ARCHIVE_READ_DAYS", defaultArchiveReadDays) +} + // NewConfig returns a new Config. func NewConfig() *Config { cfg := &Config{ diff --git a/config/config_test.go b/config/config_test.go index 1c188db..dc6112e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -708,6 +708,19 @@ func TestDisableSchedulerService(t *testing.T) { } } +func TestArchiveReadDays(t *testing.T) { + os.Clearenv() + os.Setenv("ARCHIVE_READ_DAYS", "7") + + cfg := NewConfig() + expected := 7 + result := cfg.ArchiveReadDays() + + if result != expected { + t.Fatalf(`Unexpected ARCHIVE_READ_DAYS value, got %v instead of %v`, result, expected) + } +} + func TestRunMigrationsWhenUnset(t *testing.T) { os.Clearenv() |