-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bunch of changes here, getting automod to roughly "v0". Intent is to get this PR merged, then going forward do proper code review of all future changes. New here: - "distinct value" counters (uses redis HyperLogLog; in-memory is possibly-huge `map[string]bool` - persist "flags" in redis - slack webhook notifications for "new mod actions" - fixes to exiting rules, and disable some trivial examples from "default" ruleset - new trivial/example rules, such as GTUBE spam string, counters - new rule: interaction churn (follow/unfollow) - new rule: new account reply promo - helper command to re-process most-recent N posts from an account - various helper routines in the rules package
- Loading branch information
Showing
36 changed files
with
1,485 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package automod | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMemCountStoreBasics(t *testing.T) { | ||
assert := assert.New(t) | ||
ctx := context.Background() | ||
|
||
cs := NewMemCountStore() | ||
|
||
c, err := cs.GetCount(ctx, "test1", "val1", PeriodTotal) | ||
assert.NoError(err) | ||
assert.Equal(0, c) | ||
assert.NoError(cs.Increment(ctx, "test1", "val1")) | ||
assert.NoError(cs.Increment(ctx, "test1", "val1")) | ||
c, err = cs.GetCount(ctx, "test1", "val1", PeriodTotal) | ||
assert.NoError(err) | ||
assert.Equal(2, c) | ||
|
||
c, err = cs.GetCountDistinct(ctx, "test2", "val2", PeriodTotal) | ||
assert.NoError(err) | ||
assert.Equal(0, c) | ||
assert.NoError(cs.IncrementDistinct(ctx, "test2", "val2", "one")) | ||
assert.NoError(cs.IncrementDistinct(ctx, "test2", "val2", "one")) | ||
assert.NoError(cs.IncrementDistinct(ctx, "test2", "val2", "one")) | ||
c, err = cs.GetCountDistinct(ctx, "test2", "val2", PeriodTotal) | ||
assert.NoError(err) | ||
assert.Equal(1, c) | ||
|
||
assert.NoError(cs.IncrementDistinct(ctx, "test2", "val2", "two")) | ||
assert.NoError(cs.IncrementDistinct(ctx, "test2", "val2", "three")) | ||
c, err = cs.GetCountDistinct(ctx, "test2", "val2", PeriodTotal) | ||
assert.NoError(err) | ||
assert.Equal(3, c) | ||
} |
Oops, something went wrong.