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

Github IDs and core metadata #13

Merged
merged 3 commits into from
Jun 16, 2021
Merged

Github IDs and core metadata #13

merged 3 commits into from
Jun 16, 2021

Conversation

chillu
Copy link
Member

@chillu chillu commented Jun 16, 2021

See commits for rationale.

Just for record keeping, here's the rough node script I've used to splice in the new data. It's probably a bit overkill but good way to refresh my memory on async/await :)

const fs = require('fs');
const fetch = require("node-fetch");

const TOKEN = '...';
const modules = JSON.parse(fs.readFileSync('./modules.json', 'utf8'));
// https://github.com/silverstripe/github-issue-search-client/blob/master/src/repos.json#L5
const coreModules = [
	"silverstripe/silverstripe-admin",
	"silverstripe/silverstripe-asset-admin",
	"silverstripe/silverstripe-assets",
	"silverstripe/silverstripe-campaign-admin",
	"silverstripe/silverstripe-cms",
	"silverstripe/silverstripe-config",
	"silverstripe/silverstripe-errorpage",
	"silverstripe/silverstripe-framework",
	"silverstripe/silverstripe-graphql",
	"silverstripe/silverstripe-installer",
	"silverstripe/recipe-cms",
	"silverstripe/recipe-core",
	"silverstripe/recipe-plugin",
	"silverstripe/silverstripe-reports",
	"silverstripe/silverstripe-siteconfig",
	"silverstripe/silverstripe-versioned",
	"silverstripe/silverstripe-versioned-admin",
	"silverstripe-themes/silverstripe-simple"
];

modules.reduce(async (carry, module) => {
	const url = 'https://api.github.com/repos/' + module.github;
	const response = await fetch(url, {
		headers: {
			'Authorization': 'token ' + TOKEN
		}
	});
	const id = await response.json();
	return [
		...(await carry),
		id
	];
}, Promise.resolve([])).then(ids => {
	const merged = modules.map(module => {
		// id match
		const idMatch = ids.find(id => id.full_name == module.github);
		module.githubId = idMatch ? idMatch.id : null;

		// core match
		const coreMatch = coreModules.find(coreModule => coreModule == module.github);
		module.isCore = !!coreMatch;

		return module;
	});

	console.log(JSON.stringify(merged));
});

chillu added 2 commits June 16, 2021 19:10
Repo names change over time, e.g. dnadesign/silverstripe-elemental to silverstripe/silverstripe-elemental.
Some use cases rely on unique values, for example my current attempts at community-wide data analysis through githubarchive.org.
Note that the Github GraphQL API calls this a "databaseId", and its technically deprecated in favour of a new UID value.
But all the historic Github events in githubarchive.org use the old format, so its more useful.
It's not as well defined as supported modules,
but still a useful distinction - e.g. to break down overall effort and contributions.
@chillu chillu requested a review from emteknetnz June 16, 2021 07:17
@emteknetnz emteknetnz merged commit 1ef937e into gh-pages Jun 16, 2021
@emteknetnz emteknetnz deleted the pulls/core-and-id branch June 16, 2021 21:27
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.

2 participants