Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adjust activity logic #127

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nationcred/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Each Nation3 Citizen has a NationCred score, which is used to measure how _activ

## Definition of _Active_

We define an _active_ Citizen as someone who dedicates [at least 1 hour per week](https://forum.nation3.org/t/proposal-set-q4-2022-goals/747) to Nation3.
We define an _active_ Citizen as someone who dedicates [at least 2 hour per week](https://snapshot.org/#/nation3.eth/proposal/0xc20deac472610e9bc514c0d8625809b68e2953f0609457093418afbbfa6ab65e) to Nation3.

## Datasets

19 changes: 10 additions & 9 deletions nationcred/src/generate-datasets.ts
Original file line number Diff line number Diff line change
@@ -80,14 +80,14 @@
const nowDate: Date = new Date()
console.info('nowDate:', nowDate)
while (nowDate.getTime() > weekEndDate.getTime()) {
const weekBeginDate: Date = new Date(weekEndDate.getTime() - 7*24*60*60*1000)
const weekBeginDate: Date = new Date(weekEndDate.getTime() - 7 * 24 * 60 * 60 * 1000)
console.info('week:', `[${weekBeginDate.toISOString()} → ${weekEndDate.toISOString()}]`)

// Calculate the number of hours dedicated to Nation3 value creation by the Citizen
let valueCreationHours = 0

let sourceCredScore = 0
sourceCredData.forEach((dataRow: any) => {

Check warning on line 90 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 90 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
const weekEnd = dataRow.week_end
if (weekEnd == weekEndDate.toISOString().substring(0, 10)) {
sourceCredScore = dataRow.sourcecred_score
@@ -99,7 +99,7 @@
valueCreationHours += sourceCredHours

let coordinapeMarketingHours = 0
coordinapeData.forEach((dataRow: any) => {

Check warning on line 102 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 102 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
const weekEnd = dataRow.week_end
if (weekEnd == weekEndDate.toISOString().substring(0, 10)) {
coordinapeMarketingHours = Number(dataRow.marketing_hours)
@@ -107,12 +107,12 @@
})
console.info('coordinapeMarketingHours:', coordinapeMarketingHours)
valueCreationHours += coordinapeMarketingHours

// Calculate the number of hours dedicated to Nation3 governance by the Citizen
let governanceHours = 0

let snapshotScore = 0
snapshotData.forEach((dataRow: any) => {

Check warning on line 115 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 115 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
const weekEnd = dataRow.week_end
if (weekEnd == weekEndDate.toISOString().substring(0, 10)) {
const votesCount: number = dataRow.votes_count
@@ -125,9 +125,9 @@

// Calculate the number of hours dedicated to Nation3 operations by the Citizen
let operationsHours = 0

let coordinapeOpsHours = 0
coordinapeData.forEach((dataRow: any) => {

Check warning on line 130 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 130 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
const weekEnd = dataRow.week_end
if (weekEnd == weekEndDate.toISOString().substring(0, 10)) {
coordinapeOpsHours = Number(dataRow.ops_hours)
@@ -148,12 +148,13 @@
nationCredScore2WeeksAgo = nationCredScore1WeekAgo
nationCredScore1WeekAgo = nationCredScore
const activeThreshold = 1.00
const isActive = (nationCredScore4WeeksAgo && (nationCredScore4WeeksAgo > activeThreshold))
&& (nationCredScore3WeeksAgo && (nationCredScore3WeeksAgo > activeThreshold))
&& (nationCredScore2WeeksAgo && (nationCredScore2WeeksAgo > activeThreshold))
&& (nationCredScore1WeekAgo && (nationCredScore1WeekAgo > activeThreshold))

const first2Week = (nationCredScore4WeeksAgo ?? 0) + (nationCredScore3WeeksAgo ?? 0)
const last2Week = (nationCredScore1WeekAgo ?? 0) + (nationCredScore2WeeksAgo ?? 0)

const isActive = first2Week >= activeThreshold && last2Week >= activeThreshold
console.info('isActive:', isActive)

// Export to CSV
const csvRow = {
week_end: weekEndDate.toISOString().substring(0, 10),
@@ -174,7 +175,7 @@
}
}

async function loadCSVData(filePath: string): Promise<any> {

Check warning on line 178 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 178 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
console.info('loadCSVData')

const dataFile: File = fs.readFileSync(filePath)
@@ -184,7 +185,7 @@
return new Promise(resolve => {
Papa.parse(csvData, {
header: true,
complete: (results: any) => {

Check warning on line 188 in nationcred/src/generate-datasets.ts

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 188 in nationcred/src/generate-datasets.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
console.log('complete')
resolve(results.data)
}
@@ -192,4 +193,4 @@
})
}

export {}
export { }
Loading