Skip to content

Commit

Permalink
Merge pull request pkreissel#5 from pkreissel/chaos
Browse files Browse the repository at this point in the history
feat: include last opened in chaos
  • Loading branch information
pkreissel authored Sep 29, 2023
2 parents d5a6b57 + 155063f commit 29bf3b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/scorer/feature/chaosFeatureScorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const FeatureScorer_1 = __importDefault(require("../FeatureScorer"));
const Storage_1 = __importDefault(require("../../Storage"));
class chaosFeatureScorer extends FeatureScorer_1.default {
constructor() {
super({
Expand All @@ -14,6 +15,10 @@ class chaosFeatureScorer extends FeatureScorer_1.default {
});
}
async score(api, status) {
if (status.topPost)
return 0;
const lastOpened = await Storage_1.default.getLastOpened() || 0;
const percent = (Date.now() - lastOpened) < (1000 * 60 * 60 * 6) ? 0.5 : 0.9;
return Math.random() > 0.9 ? 1 : 0;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/scorer/feature/chaosFeatureScorer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FeatureScorer from '../FeatureScorer'
import { StatusType, accFeatureType } from '../../types'
import { mastodon } from 'masto'
import Storage from '../../Storage'

export default class chaosFeatureScorer extends FeatureScorer {
constructor() {
Expand All @@ -13,6 +14,8 @@ export default class chaosFeatureScorer extends FeatureScorer {
}
async score(api: mastodon.rest.Client, status: StatusType) {
if (status.topPost) return 0
const lastOpened = await Storage.getLastOpened() || 0
const percent = (Date.now() - lastOpened) < (1000 * 60 * 60 * 6) ? 0.5 : 0.9
return Math.random() > 0.9 ? 1 : 0
}
}

0 comments on commit 29bf3b2

Please sign in to comment.