Skip to content

Monthly stats 2025-06#1

Open
2u841r wants to merge 3 commits intoQuad9DNS:mainfrom
2u841r:monthly
Open

Monthly stats 2025-06#1
2u841r wants to merge 3 commits intoQuad9DNS:mainfrom
2u841r:monthly

Conversation

@2u841r
Copy link

@2u841r 2u841r commented Jul 29, 2025

position
The domain’s rank position in the monthly list, sorted by average rank ascending (1 = best rank).

domain_name
The domain’s name (e.g., "google.com", "kkgde4d1.click").

avg
The average position of the domain across all days it appeared in the daily top 500 lists. This is a decimal number representing the mean rank.

median
The median position of the domain across all days it appeared. The median is less sensitive to outliers compared to average.

days
The count of days in the month the domain appeared in the daily top 500 lists (maximum 30 for June).

@2u841r
Copy link
Author

2u841r commented Jul 29, 2025

monthly.js

const fs = require("fs");
const path = require("path");

const FOLDER = "./top500"; // Folder containing 30 JSON files
const domainStats = {};

// Read all files matching the pattern
const files = fs.readdirSync(FOLDER).filter(f => f.startsWith("top500-2025-06") && f.endsWith(".json"));

for (const file of files) {
  const lines = fs.readFileSync(path.join(FOLDER, file), "utf-8").split("\n").filter(Boolean);

  for (const line of lines) {
    try {
      const { position, domain_name } = JSON.parse(line.trim());

      if (!domainStats[domain_name]) {
        domainStats[domain_name] = [];
      }

      domainStats[domain_name].push(position);
    } catch (e) {
      console.error(`Error parsing line in ${file}:`, line);
    }
  }
}

// Utility to calculate average
function average(arr) {
  return arr.reduce((sum, val) => sum + val, 0) / arr.length;
}

// Utility to calculate median
function median(arr) {
  const sorted = [...arr].sort((a, b) => a - b);
  const mid = Math.floor(sorted.length / 2);
  return sorted.length % 2 === 0
    ? (sorted[mid - 1] + sorted[mid]) / 2
    : sorted[mid];
}

// Create result array with domain + average + median
const result = Object.entries(domainStats).map(([domain, positions]) => ({
  domain,
  count: positions.length,
  avg: average(positions),
  median: median(positions)
}));

// Sort by average position (you can change to median if preferred)
result.sort((a, b) => a.avg - b.avg);

// Output top N or all
for (let i = 0; i < result.length; i++) {
  const { domain, avg, median, count } = result[i];
  console.log(`${i + 1}. ${domain} | avg: ${avg.toFixed(2)} | median: ${median} | days: ${count}`);
}


const outputPath = path.join(FOLDER, "top500-2025-06-monthly.json");

const outputLines = result.map((entry, i) => JSON.stringify({
  position: i + 1,
  domain_name: entry.domain,
  avg: Number(entry.avg.toFixed(2)),
  median: entry.median,
  days: entry.count
}));

fs.writeFileSync(outputPath, outputLines.join("\n"), "utf-8");
console.log(`Saved to ${outputPath}`);

@2u841r 2u841r mentioned this pull request Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant