mirror of
https://github.com/10h30/blog-balodeplao.git
synced 2026-05-12 15:21:15 +09:00
chore: remove traffic tracking files and related workflow
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
@@ -1,101 +0,0 @@
|
|||||||
{
|
|
||||||
"count": 444,
|
|
||||||
"uniques": 280,
|
|
||||||
"clones": [
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-16T00:00:00Z",
|
|
||||||
"count": 3,
|
|
||||||
"uniques": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-17T00:00:00Z",
|
|
||||||
"count": 0,
|
|
||||||
"uniques": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-18T00:00:00Z",
|
|
||||||
"count": 0,
|
|
||||||
"uniques": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-19T00:00:00Z",
|
|
||||||
"count": 0,
|
|
||||||
"uniques": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-20T00:00:00Z",
|
|
||||||
"count": 0,
|
|
||||||
"uniques": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-21T00:00:00Z",
|
|
||||||
"count": 18,
|
|
||||||
"uniques": 14
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-22T00:00:00Z",
|
|
||||||
"count": 41,
|
|
||||||
"uniques": 25
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-23T00:00:00Z",
|
|
||||||
"count": 15,
|
|
||||||
"uniques": 14
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-24T00:00:00Z",
|
|
||||||
"count": 34,
|
|
||||||
"uniques": 23
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-25T00:00:00Z",
|
|
||||||
"count": 17,
|
|
||||||
"uniques": 13
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-26T00:00:00Z",
|
|
||||||
"count": 14,
|
|
||||||
"uniques": 12
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-27T00:00:00Z",
|
|
||||||
"count": 30,
|
|
||||||
"uniques": 17
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-02-28T00:00:00Z",
|
|
||||||
"count": 21,
|
|
||||||
"uniques": 11
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-01T00:00:00Z",
|
|
||||||
"count": 82,
|
|
||||||
"uniques": 31
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-02T00:00:00Z",
|
|
||||||
"count": 74,
|
|
||||||
"uniques": 42
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-03T00:00:00Z",
|
|
||||||
"count": 37,
|
|
||||||
"uniques": 27
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-04T00:00:00Z",
|
|
||||||
"count": 17,
|
|
||||||
"uniques": 14
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-05T00:00:00Z",
|
|
||||||
"count": 25,
|
|
||||||
"uniques": 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": "2026-03-06T00:00:00Z",
|
|
||||||
"count": 16,
|
|
||||||
"uniques": 14
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
import fs from "node:fs";
|
|
||||||
|
|
||||||
async function saveTraffic() {
|
|
||||||
const token = process.env.GRAPH_TOKEN;
|
|
||||||
const repo =
|
|
||||||
process.env.GITHUB_REPOSITORY || "devgelo-labs/astro-starter-pro";
|
|
||||||
const filePath = "./.github/data/clones.json";
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`https://api.github.com/repos/${repo}/traffic/clones`,
|
|
||||||
{
|
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error(`GitHub API error: ${response.statusText}`);
|
|
||||||
|
|
||||||
const apiData = await response.json();
|
|
||||||
|
|
||||||
let localData = { count: 0, uniques: 0, clones: [] };
|
|
||||||
|
|
||||||
// 1. Si el archivo ya existe, leerlo
|
|
||||||
if (fs.existsSync(filePath)) {
|
|
||||||
try {
|
|
||||||
localData = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
||||||
} catch {
|
|
||||||
console.warn(
|
|
||||||
"⚠️ Warning: Error reading existing clones.json, starting fresh.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Unir (Merge) los clones nuevos con los viejos sin duplicar fechas
|
|
||||||
const combinedClones = [...localData.clones];
|
|
||||||
|
|
||||||
apiData.clones.forEach((newClone) => {
|
|
||||||
const index = combinedClones.findIndex(
|
|
||||||
(c) => c.timestamp === newClone.timestamp,
|
|
||||||
);
|
|
||||||
if (index !== -1) {
|
|
||||||
// Si el día ya existe, actualizamos los números (por si subieron durante el día)
|
|
||||||
combinedClones[index] = newClone;
|
|
||||||
} else {
|
|
||||||
// Si el día es nuevo, lo agregamos
|
|
||||||
combinedClones.push(newClone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. Ordenar por fecha y actualizar totales globales
|
|
||||||
combinedClones.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
|
|
||||||
|
|
||||||
const totalCount = combinedClones.reduce((sum, c) => sum + c.count, 0);
|
|
||||||
const totalUniques = combinedClones.reduce((sum, c) => sum + c.uniques, 0);
|
|
||||||
|
|
||||||
const finalData = {
|
|
||||||
count: totalCount,
|
|
||||||
uniques: totalUniques,
|
|
||||||
clones: combinedClones,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!fs.existsSync("./.github/data"))
|
|
||||||
fs.mkdirSync("./.github/data", { recursive: true });
|
|
||||||
fs.writeFileSync(filePath, JSON.stringify(finalData, null, 2));
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
`✅ Historial actualizado: ${combinedClones.length} días registrados.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveTraffic().catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
name: Save Repo Traffic
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * 0"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "18"
|
|
||||||
|
|
||||||
- name: Fetch and Save Data
|
|
||||||
env:
|
|
||||||
GRAPH_TOKEN: ${{ secrets.GRAPH_TOKEN }}
|
|
||||||
run: node .github/save_traffic.js
|
|
||||||
|
|
||||||
- name: Commit and Push changes
|
|
||||||
run: |
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add .github/data/clones.json
|
|
||||||
git commit -m "data: update traffic clones" || exit 0
|
|
||||||
git push
|
|
||||||
Reference in New Issue
Block a user