Optimize the database size, make the CI use concurrency (and rename the compose script for clarity)

This commit is contained in:
Yuri Sizov
2021-08-24 16:51:42 +03:00
parent 7ca5d44158
commit f8a1ec7166
4 changed files with 30 additions and 11 deletions

View File

@@ -7,6 +7,11 @@ on:
# Every day every two hours starting at midnight (UTC).
- cron: '0 0,2,4,6,8,10,12,14,16,18,20,22 * * *'
# Make sure jobs cannot overlap (e.g. one from push and one from schedule).
concurrency:
group: pages-ci
cancel-in-progress: true
jobs:
build:
name: Build and deploy to GitHub Pages
@@ -28,7 +33,7 @@ jobs:
run: npm run build
- name: Fetch pull request data
run: npm run compose
run: npm run compose-db
- name: Deploy to GitHub Pages 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3

View File

@@ -20,7 +20,7 @@ should work just fine).
1. Clone or download the project.
2. From the project root run `npm install` or `yarn` to install dependencies.
3. Run `npm run build` or `yarn run build` to build the pages.
4. Run `npm run compose` or `yarn run compose` to fetch the data from GitHub.
4. Run `npm run compose-db` or `yarn run compose-db` to fetch the data from GitHub.
5. Serve the `out/` folder with your method of choice (e.g. using Python 3:
`python -m http.server 8080 -d ./out`).

View File

@@ -3,6 +3,7 @@ const path = require('path');
const fetch = require('node-fetch');
const teams = {};
const authors = {};
const pulls = [];
let page_count = 1;
@@ -51,15 +52,9 @@ function processPulls(pullsRaw) {
"title": item.title,
"state": item.state,
"is_draft": item.draft,
"authored_by": {
"id": item.user.id,
"user": item.user.login,
"avater": item.user.avatar_url,
"url": item.user.html_url,
},
"authored_by": null,
"created_at": item.created_at,
"updated_at": item.updated_at,
"body": item.body,
"target_branch": item.base.ref,
@@ -69,6 +64,22 @@ function processPulls(pullsRaw) {
"teams": [],
};
// Compose and link author information.
const author = {
"id": item.user.id,
"user": item.user.login,
"avatar": item.user.avatar_url,
"url": item.user.html_url,
"pull_count": 0,
};
pr.authored_by = author.id;
// Store the author if they haven't been stored.
if (typeof authors[author.id] == "undefined") {
authors[author.id] = author;
}
authors[author.id].pull_count++;
// Add the milestone, if available.
if (item.milestone) {
pr.milestone = {
@@ -94,13 +105,14 @@ function processPulls(pullsRaw) {
// Add teams, if available.
item.requested_teams.forEach((teamItem) => {
let team = {
const team = {
"id": teamItem.id,
"name": teamItem.name,
"avatar": `https://avatars.githubusercontent.com/t/${teamItem.id}?s=40&v=4`,
"slug": teamItem.slug,
"full_name": teamItem.name,
"full_slug": teamItem.slug,
"pull_count": 0,
};
// Include parent data into full name and slug.
if (teamItem.parent) {
@@ -112,6 +124,7 @@ function processPulls(pullsRaw) {
if (typeof teams[team.id] == "undefined") {
teams[team.id] = team;
}
teams[team.id].pull_count++;
// Reference the team.
pr.teams.push(team.id);
@@ -137,6 +150,7 @@ async function main() {
const output = {
"generated_at": Date.now(),
"teams": teams,
"authors": authors,
"pulls": pulls,
};
try {

View File

@@ -4,7 +4,7 @@
"description": "",
"scripts": {
"build": "./node_modules/.bin/rollup -c",
"compose": "node ./compose.js"
"compose-db": "node ./compose-db.js"
},
"author": "Yuri Sizov <yuris@humnom.net>",
"private": true,