-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.js
168 lines (135 loc) · 4.88 KB
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Core dependencies
const path = require('path')
const fs = require('fs')
// Check for node_modules before running
const checkFiles = require('./lib/build/check-files').checkFiles
checkFiles()
// Local dependencies
const { buildWatchAndServe } = require('./lib/build/tasks')
const { projectDir } = require('./lib/utils')
async function collectDataUsage() {
// Local dependencies
const usageData = require('./lib/usage_data')
// Get usageDataConfig from file, if exists
const usageDataConfig = usageData.getUsageDataConfig()
if (usageDataConfig.collectUsageData === undefined) {
// No recorded answer, so ask for permission
const permissionGranted = await usageData.askForUsageDataPermission()
usageDataConfig.collectUsageData = permissionGranted
usageData.setUsageDataConfig(usageDataConfig)
if (permissionGranted) {
usageData.startTracking(usageDataConfig)
}
} else {
if (usageDataConfig.collectUsageData === true) {
// Opted in
usageData.startTracking(usageDataConfig)
}
}
}
function createSessionDataDefaults() {
// Create template session data defaults file if it doesn't exist
const dataDirectory = path.join(projectDir, '/app/data')
const sessionDataDefaultsFile = path.join(dataDirectory, '/session-data-defaults.js')
const sessionDataDefaultsFileExists = fs.existsSync(sessionDataDefaultsFile)
if (!sessionDataDefaultsFileExists) {
console.log('Creating session data defaults file')
if (!fs.existsSync(dataDirectory)) {
fs.mkdirSync(dataDirectory)
}
fs.createReadStream(path.join(__dirname, '/lib/template.session-data-defaults.js'))
.pipe(fs.createWriteStream(sessionDataDefaultsFile))
}
}
(async () => {
console.log('createSessionDataDefaults');
createSessionDataDefaults()
await collectDataUsage()
await buildWatchAndServe()
})()
// call IFATE and get current list of standards
// parse the data for version and status counts
/*
require("request").get("https://www.instituteforapprenticeships.org/api/apprenticeshipstandards", (error, response, body) => {
var _apiData = JSON.parse(body),
_versionTypes = {},
_ksb = 0,
_status = {};
console.log(_apiData.length + " standards in API (https://www.instituteforapprenticeships.org/api/apprenticeshipstandards)");
_apiData.forEach(function(_standard, index) {
_status["status " + _standard.status] = (_status["status " + _standard.status] || 0) + 1;
_versionTypes["version " + _standard.version] = (_versionTypes["version " + _standard.version] || 0) + 1;
if(_standard.knowledges.length>0 && _standard.status=="Approved for delivery"){
console.log(_standard.larsCode, _standard.status, _standard.knowledges.length, _standard.knowledges);
_ksb ++;
}
});
console.log(_versionTypes);
console.log(_status);
console.log(_ksb);
});
*/
// 17 Jan 2023
/*
1050 standards in API (https://www.instituteforapprenticeships.org/api/apprenticeshipstandards)
{
'version 0.0': 130,
'version 1.1': 186,
'version 1.0': 689,
'version 1.2': 34,
'version 1.3': 9,
'version 2.0': 2
}
{
'status Withdrawn': 46,
'status In development': 74,
'status Approved for delivery': 659,
'status Proposal in development': 12,
'status Retired': 259
}
*/
var standards = require('./app/data/apprenticeshipstandards.json')
const { listenerCount } = require('process')
//console.log(standards);
//loop thru standards and get those with / wo KSB
/*
var _list = [];
standards.forEach(function(_standard, index) {
if(_standard.larsCode != 0 ){
let obj = {larsCode:_standard.larsCode , title:_standard.title, level: _standard.level };
_list.push(obj);
}
})
_list.sort(function(a, b) {
if ( a.title < b.title ){
return -1;
}
if ( a.title > b.title ){
return 1;
}
return 0;
})
*/
//console.log(_list);
/* _list.forEach(function(_standard, index) {
console.log('<option value="' + _standard.larsCode + '">' + _standard.title + ', Level: ' + _standard.level + '</option>');
}); */
/* require("request").get("data/apprenticeshipstandards", (error, response, body) => {
var _apiData = JSON.parse(body),
_versionTypes = {},
_ksb = 0,
_status = {};
console.log(_apiData.length + " standards in API (https://www.instituteforapprenticeships.org/api/apprenticeshipstandards)");
_apiData.forEach(function(_standard, index) {
_status["status " + _standard.status] = (_status["status " + _standard.status] || 0) + 1;
_versionTypes["version " + _standard.version] = (_versionTypes["version " + _standard.version] || 0) + 1;
if(_standard.knowledges.length>0 && _standard.status=="Approved for delivery"){
console.log(_standard.larsCode, _standard.status, _standard.knowledges.length, _standard.knowledges);
_ksb ++;
}
});
console.log(_versionTypes);
console.log(_status);
console.log(_ksb);
});
*/