Skip to content

Commit de4eb82

Browse files
committed
Small tweaks
1 parent dd091bd commit de4eb82

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ if (jsonData == 'Error') {
2121
const fs = require('fs');
2222
const path = require('path'); //base_path = path.resolve();
2323
const base_path = __dirname || process.cwd();
24-
const target_path = path.resolve(base_path + '\\data\\json\\');
24+
const target_path = path.resolve(base_path + '\\data\\json');
2525
const target_ext = '.json';
2626

2727
const local_debug = Boolean ( 0 );
28+
const local_verbose = Boolean ( 1 );
2829

2930

3031
function read_files(target_path) {
@@ -84,8 +85,10 @@ function get_score(data) {
8485
'relations_count': {}
8586
};
8687
for (const project_data of Object.values(data)) {
87-
if (!project_data.meta.added_by) console.log('No "Added by" field:', project_data);
88-
if (!project_data.name) console.log('No "Added by" field:', project_data);
88+
//console.log("project_data", project_data);
89+
//if (!project_data.meta) console.log('No "Meta" field:', project_data);
90+
//if (!project_data.meta.added_by) console.log('No "Added by" field:', project_data);
91+
//if (!project_data.name) console.log('No "Added by" field:', project_data);
8992

9093
if (!score.adders[project_data.meta.added_by]) score.adders[project_data.meta.added_by] = 0;
9194
if (!score.relations_count[project_data.name]) score.relations_count[project_data.name] = 0;
@@ -113,10 +116,6 @@ function get_score(data) {
113116
return score;
114117
}
115118

116-
function require_project(project_id) {
117-
return require(target_path + project_id + target_ext) || false;
118-
}
119-
120119
// http://stackoverflow.com/a/25500462/8175291
121120
function dict_sort(dict, keys_pos_inverted = true) {
122121
// Create items array
@@ -158,16 +157,16 @@ async function main() {
158157

159158
console.log('base_path:', base_path);
160159
console.log('target_path:', target_path);
161-
console.log('target_ext:', target_ext);
160+
//console.log('target_ext:', target_ext);
162161

163162
//const jsonData = require_project('000');
164163
//console.log('jsonData:', jsonData);
165164

166165
const _out = read_files(target_path);
167-
console.log('read_files (1):', _out);
166+
if (local_verbose) console.log('read_files (1):', _out);
168167

169168
const score = get_score(_out);
170-
console.log('get_score (1):', score);
169+
if (local_verbose) console.log('get_score (1):', score);
171170

172171

173172
const _out2 = read_files(target_path + '\\outsourcing\\');

tools/merger.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ async function main() {
7979

8080
//sorted_json = JSON.dumps(_out2, sort_keys = true)
8181
var stringified = JSON.stringify(_out2["data"], null, "\t");
82-
await fs.writeFileSync(target_path + '\\_data.json', stringified, {encoding: 'utf8'}, (err) => err && console.error(err));
82+
await fs.writeFileSync(path.resolve(target_path + + '\\..\\merged\\_data.json'), stringified, {encoding: 'utf8'}, (err) => err && console.error(err));
8383

8484
//for (let project_id in _out2["data"]) {
85-
// fs.appendFile(target_path + '\\_data.json', JSON.stringify({project_id: _out2["data"][project_id]}, null, "\t"), {encoding: 'utf8'}, (err) => err && console.error(err));
85+
// fs.appendFile(path.resolve(target_path + + '\\..\\merged\\_data.json'), JSON.stringify({project_id: _out2["data"][project_id]}, null, "\t"), {encoding: 'utf8'}, (err) => err && console.error(err));
8686
//}
8787

88-
await s_json.overwrite(target_path + '\\_data.json', options);
89-
//await fs.writeFileSync(target_path + '\\_data.json', json_ks.sort(_out2["data"], true), {encoding: 'utf8'}, (err) => err && console.error(err));
88+
await s_json.overwrite(path.resolve(target_path + + '\\..\\merged\\_data.json'), options);
89+
//await fs.writeFileSync(path.resolve(target_path + + '\\..\\merged\\_data.json'), json_ks.sort(_out2["data"], true), {encoding: 'utf8'}, (err) => err && console.error(err));
9090
//console.log(json_ks.sort(_out2["data"], true))
9191

9292
}

0 commit comments

Comments
 (0)