mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-17 13:08:49 +03:00
fix countcontributingusers
This commit is contained in:
@@ -9,7 +9,7 @@ describe("getTotalStats", () => {
|
||||
it("Can get total stats", async () => {
|
||||
const result = await client({ url: endpoint });
|
||||
const data = result.data;
|
||||
assert.ok(data.userCount >= 0);
|
||||
assert.strictEqual(data.userCount, 0, "User count should default false");
|
||||
assert.ok(data.activeUsers >= 0);
|
||||
assert.ok(data.apiUsers >= 0);
|
||||
assert.ok(data.viewCount >= 0);
|
||||
@@ -31,9 +31,9 @@ describe("getTotalStats", () => {
|
||||
it("Can get total stats with old cws method", async () => {
|
||||
const stub = sinon.stub(getCWSUsers, "getCWSUsers");
|
||||
stub.resolves(undefined);
|
||||
const result = await client({ url: `${endpoint}?countContributingUsers=false` });
|
||||
const result = await client({ url: `${endpoint}?countContributingUsers=true` });
|
||||
const data = result.data;
|
||||
assert.strictEqual(data.userCount, 0);
|
||||
assert.ok(data.userCount >= 0);
|
||||
assert.ok(data.activeUsers >= 0);
|
||||
assert.ok(data.apiUsers >= 0);
|
||||
assert.ok(data.viewCount >= 0);
|
||||
|
||||
@@ -20,8 +20,8 @@ async function init() {
|
||||
// delete old test database
|
||||
if (fs.existsSync(config.db)) fs.unlinkSync(config.db);
|
||||
if (fs.existsSync(config.privateDB)) fs.unlinkSync(config.privateDB);
|
||||
await resetRedis();
|
||||
await resetPostgres();
|
||||
if (config?.redis?.enabled) await resetRedis();
|
||||
if (config?.postgres) await resetPostgres();
|
||||
|
||||
await initDb();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Pool } from "pg";
|
||||
import { Logger } from "../../src/utils/logger";
|
||||
|
||||
export async function resetRedis() {
|
||||
if (config.redis) {
|
||||
if (config?.redis?.enabled) {
|
||||
const client = createClient(config.redis);
|
||||
await client.connect();
|
||||
await client.flushAll();
|
||||
|
||||
Reference in New Issue
Block a user