mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Lazy-load recommendation indexes
This commit is contained in:
1 parent
fe976b3ab7
commit
5f439d6863
5 files changed
+104
-20
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import ExploreDataService from "../../js/services/exploreDataService.js";
|
||||
|
||||
test("ExploreDataService stays idle until a recommendation feed activates it", async () => {
|
||||
const service = new ExploreDataService({
|
||||
historyRefreshIntervalMs: 0,
|
||||
idfRefreshIntervalMs: 0,
|
||||
});
|
||||
let historyRefreshes = 0;
|
||||
let idfRefreshes = 0;
|
||||
service.refreshWatchHistoryTagCounts = async () => {
|
||||
historyRefreshes += 1;
|
||||
return new Map();
|
||||
};
|
||||
service.refreshTagIdf = async () => {
|
||||
idfRefreshes += 1;
|
||||
return new Map();
|
||||
};
|
||||
|
||||
await service.initialize();
|
||||
assert.equal(historyRefreshes, 0);
|
||||
assert.equal(idfRefreshes, 0);
|
||||
|
||||
service.queueWatchHistoryRefresh("note");
|
||||
service.queueTagIdfRefresh("note");
|
||||
await service.setActive(true);
|
||||
assert.equal(historyRefreshes, 1, "dirty history is refreshed on activation");
|
||||
assert.equal(idfRefreshes, 1, "dirty IDF is refreshed on activation");
|
||||
|
||||
await service.setActive(false);
|
||||
service.queueTagIdfRefresh("inactive-note");
|
||||
assert.equal(idfRefreshes, 1, "inactive feeds do not rebuild recommendation indexes");
|
||||
service.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user