Skip to content

Commit e0db979

Browse files
committed
feat: update activity logic
1 parent ae59a7b commit e0db979

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

nationcred/src/generate-datasets.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,12 @@ async function loadNationCredData() {
148148
nationCredScore2WeeksAgo = nationCredScore1WeekAgo
149149
nationCredScore1WeekAgo = nationCredScore
150150
const activeThreshold = 1.00
151-
const isActive = (nationCredScore4WeeksAgo && (nationCredScore4WeeksAgo > activeThreshold))
152-
&& (nationCredScore3WeeksAgo && (nationCredScore3WeeksAgo > activeThreshold))
153-
&& (nationCredScore2WeeksAgo && (nationCredScore2WeeksAgo > activeThreshold))
154-
&& (nationCredScore1WeekAgo && (nationCredScore1WeekAgo > activeThreshold))
155-
console.info('isActive:', isActive)
156151

157-
const isInactive = nationCredScore1WeekAgo && (nationCredScore1WeekAgo <= activeThreshold)
158-
&& nationCredScore2WeeksAgo && (nationCredScore2WeeksAgo <= activeThreshold);
152+
let first2Week = (nationCredScore4WeeksAgo ?? 0) + (nationCredScore3WeeksAgo ?? 0)
153+
let last2Week = (nationCredScore1WeekAgo ?? 0) + (nationCredScore2WeeksAgo ?? 0)
154+
155+
const isActive = first2Week >= activeThreshold && last2Week >= activeThreshold
156+
console.info('isActive:', isActive)
159157

160158
// Export to CSV
161159
const csvRow = {
@@ -165,7 +163,7 @@ async function loadNationCredData() {
165163
operations_hours: Number(operationsHours.toFixed(2)),
166164
nationcred_score: Number(nationCredScore.toFixed(2)),
167165
nationcred_score_accumulated: Number(nationCredScoreAccumulated.toFixed(2)),
168-
is_active: Boolean(isActive && !isInactive)
166+
is_active: Boolean(isActive)
169167
}
170168
csvRows.push(csvRow)
171169

0 commit comments

Comments
 (0)