Background
Message from Telegram, the day when $ARB
airdrop was announced:
3 minutes video explanation
Google Doc
Raw processed data
CSV output 7KB
: https://gateway.ipfs.io/ipfs/QmPWyy1TJP7MNSjL7JDhHxUUqpyCSRVA4gWMTWoxV3U3km
Code
Need to have raw data.json
, copy on Telegram here
- Have node.js installed
- npm install fs
- node index.js > output.csv
// index.js
const fs = require('fs');
let data = {}
fs.readFile('data.json', 'utf8', (error, file) => {
if (error) {
console.error(`Error reading file: ${error}`);
return;
}
let oneDay = 86400;
const jsonData = JSON.parse(file);
for (let i=0; i<jsonData.messages.length; i++) {
let message = jsonData.messages[i];
if (message.from_id) {
if( !data[message.from_id]) { // Creating entry for the user
data[message.from_id] = {
messages: 1, // encountered new user, their first message, so setting to 1
last_action: message.date_unixtime,
current_period_start: message.date_unixtime,
longest_period: 1, // if we ever encounter a user with only one message, this will be 1
periods_count: 1,
}
} else {
data[message.from_id].messages++
if (message.date_unixtime - data[message.from_id].last_action > oneDay) {
data[message.from_id].periods_count++
let current_period_length_in_days = Math.ceil( (data[message.from_id].last_action - data[message.from_id].current_period_start) / oneDay );
if(current_period_length_in_days > data[message.from_id].longest_period) {
data[message.from_id].longest_period = current_period_length_in_days
}
data[message.from_id].current_period_start = message.date_unixtime
}
data[message.from_id].last_action = message.date_unixtime
}
}
// Invite, Remove, Pin message = negligible
}
// Need to account for the last period
for (key in data) {
let current_period_length_in_days = Math.ceil( (data[key].last_action - data[key].current_period_start) / oneDay );
if(current_period_length_in_days > data[key].longest_period) {
data[key].longest_period = current_period_length_in_days
}
}
const uniqueUsers = Object.keys(data).length;
// console.log("UNIQUE USERS: ", uniqueUsers);
// PRINT CSV
console.log("User ID,Message Count,Longest Period,Periods Count");
for (key in data) {
console.log(key + "," + data[key].messages + "," + data[key].longest_period + "," + data[key].periods_count);
}
});
Full snapshot of everything (maybe one day)
- All the Telegram chats
- All the smart contracts
- All the GitHub repos
- Forum
- Slack
- Discord
You can imagine any number of data points. For now - one chat - reasonably simple metrics.
Related: https://sourcecred.io - product ahead of the curve, loads of potential in revisiting.
Next steps
- Review the proposed allocation
- A simple website “log in with Telegram” to input ETH address
- Probably will use XDAI chain
- Feedback, comments, suggestions, ideas