Skip to content

Commit 2b3d6c0

Browse files
committed
Initial commit
1 parent 88679d4 commit 2b3d6c0

File tree

20 files changed

+1710
-0
lines changed

20 files changed

+1710
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Basic Reporting'
2+
description: 'Generates basic reports for companies and studies plus wrapping README.md files in the repository'
3+
inputs:
4+
github-token:
5+
description: 'GitHub token'
6+
required: true
7+
runs:
8+
using: 'node20'
9+
main: 'index.js'
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
const mrMarkdownBuilder = require('mr_markdown_builder')
2+
3+
// Globals
4+
const MAPS_WARNING = `**Notice:** If you are using Safari and had previously disabled \`Prevent cross-site tracking\` feature in the \`Privacy tab\` in Safari's preferences, you can now reenable it since this bug has been fixed by GitHub.${mrMarkdownBuilder.cr()}${mrMarkdownBuilder.cr()}`
5+
6+
function createCompaniesMap (companies) {
7+
// Filter out companies with unknown latitude or longitude
8+
companies = companies.filter((company) => company.latitude !== 'Unknown' && company.longitude !== 'Unknown')
9+
// Create the map
10+
let map = mrMarkdownBuilder.h1('Company Locations')
11+
map += MAPS_WARNING
12+
map += mrMarkdownBuilder.geojson({
13+
type: 'FeatureCollection',
14+
features: companies.map((company) => {
15+
return {
16+
type: 'Feature',
17+
geometry: {
18+
type: 'Point',
19+
coordinates: [company.longitude, company.latitude]
20+
},
21+
properties: {
22+
name: company.name,
23+
description: company.description,
24+
role: company.role,
25+
url: company.url
26+
}
27+
}
28+
})
29+
})
30+
// return the map
31+
return mrMarkdownBuilder.cr() + map
32+
}
33+
34+
function createTableOfCompanies (companies) {
35+
// Create the table header
36+
const tableHeader = mrMarkdownBuilder.tableHeader(['Company Name', 'Company Type', 'Company Role', 'Company Region', 'Total Interactions'])
37+
// Count the total interactions for each company by looking at the number of keys in linked_interactions
38+
companies.forEach((company) => {
39+
company.total_interactions = Object.keys(company.linked_interactions).length
40+
})
41+
42+
// Create the table rows
43+
const tableRows = companies.map((company) => {
44+
const companyRow = [
45+
mrMarkdownBuilder.link(company.name, `./${encodeURI(company.name.replace(/[\s,.\?!]/g, ''))}.md`),
46+
company.company_type,
47+
company.role,
48+
company.region,
49+
company.total_interactions
50+
]
51+
return companyRow
52+
})
53+
// Create the table
54+
const companyTable = tableHeader + "\n" + mrMarkdownBuilder.tableRows(tableRows)
55+
// Return the table
56+
return companyTable
57+
}
58+
59+
function createCompaniesReport (companies) {
60+
let readme = `[${mrMarkdownBuilder.link('Back to main README', '../README.md')}]\n`
61+
readme += mrMarkdownBuilder.hr()
62+
readme += mrMarkdownBuilder.h1('Introduction')
63+
readme += `There are currently \`${companies.length}\` companies in the repository. The table below lists all available companies and some of their firmographics. Click on the company name to view the company's profile. Below the table is a map of all companies in the repository. Click on a company's marker to view additional company information in context.`
64+
readme += mrMarkdownBuilder.h1('Table of Companies')
65+
// // Create the table header
66+
// const tableHeader = mrMarkdownBuilder.tableHeader(['Company Name', 'Company Type', 'Company Role', 'Company Region'])
67+
// // Create the table rows
68+
// const tableRows = companies.map((company) => {
69+
// const companyRow = [
70+
// mrMarkdownBuilder.link(company.name, `./${encodeURI(company.name.replace(/[\s,.\?!]/g, ''))}.md`),
71+
// company.company_type,
72+
// company.role,
73+
// company.region
74+
// ]
75+
// return companyRow
76+
// })
77+
// // Create the table
78+
// const companyTable = tableHeader + "\n" + mrMarkdownBuilder.tableRows(tableRows)
79+
const companyTable = createTableOfCompanies(companies)
80+
// Create the README.md file
81+
readme += companyTable
82+
// Add a line break
83+
readme += mrMarkdownBuilder.cr() + mrMarkdownBuilder.hr()
84+
// Call the createMap function
85+
readme += mrMarkdownBuilder.cr() + createCompaniesMap(companies)
86+
// Return the file content
87+
return readme
88+
89+
}
90+
91+
module.exports = {
92+
createCompaniesReport,
93+
createTableOfCompanies
94+
}

0 commit comments

Comments
 (0)