Skip to content

Commit b68e3fd

Browse files
committed
Add new stations
1 parent db24fe8 commit b68e3fd

File tree

4 files changed

+2443
-872
lines changed

4 files changed

+2443
-872
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
old.json
26+
result.json

src/components/Station.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import branchColors from '../constants/branch'
2525
import industryColors from '../constants/industry'
2626

2727
const Station = (props) => {
28-
const { name, location, industry, projects, branches, stationId } = props.data
28+
const { name, location, industry, projects, branches, stationId, } = props.data
2929

3030
const { isOpen, onOpen, onClose } = useDisclosure()
3131

@@ -77,7 +77,17 @@ const Station = (props) => {
7777
}}
7878
>
7979
<Td>{props.idx + 1}</Td>
80-
<Td onClick={onOpen}>{name}</Td>
80+
<Td onClick={onOpen}>
81+
{
82+
props.data.new
83+
? <Badge colorScheme='green' mb='8px'>New</Badge>
84+
: null
85+
}
86+
<Box>
87+
{name}
88+
</Box>
89+
</Td>
90+
8191
<Td onClick={onOpen}>
8292
{
8393
<Badge colorScheme={industryColors[industry]}>{industry}</Badge>

src/data/extractIndustries.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
const data = require('./ps1_data.json')
1+
const data = require('./result.json')
2+
const old = require('./ps1_data.json')
23
const fs = require('fs')
34
const path = require('path')
45

56
const industries = {}
67
data.forEach(({ industry }) => industries[industry] = true)
78

8-
// data.forEach((station) => {
9-
// if (!station.projects) {
10-
// return
11-
// }
12-
// let branches = {}
13-
// station.projects.forEach((proj) => {
14-
// proj.preferredDisciplines.forEach((disc) => branches[disc] = true)
15-
// })
16-
// branches = Object.keys(branches)
17-
// station.branches = branches
18-
// })
9+
const oldStations = {}
10+
old.forEach(({stationId}) => oldStations[stationId] = true)
11+
console.log(oldStations)
12+
13+
data.forEach((station) => {
14+
if (!station.projects) {
15+
return
16+
}
17+
let branches = {}
18+
station.projects.forEach((proj) => {
19+
proj.preferredDisciplines.forEach((disc) => branches[disc] = true)
20+
})
21+
branches = Object.keys(branches)
22+
station.branches = branches
23+
})
1924

2025
function cleanArray(array) {
2126
let clArray = {}
@@ -31,9 +36,19 @@ data.forEach((station) => {
3136
station.projects.forEach((proj) => proj.preferredDisciplines = cleanArray(proj.preferredDisciplines))
3237
})
3338

39+
data.forEach((station) => {
40+
if (!oldStations[station.stationId]) {
41+
station.new = true
42+
} else {
43+
station.new = false
44+
}
45+
})
46+
3447
fs.writeFileSync(
3548
path.join(__dirname, 'ps1_data1.json'),
3649
JSON.stringify(data, null, 4)
3750
)
3851

52+
console.log(data.length)
53+
3954
console.log(industries)

0 commit comments

Comments
 (0)