Skip to content

Commit a681871

Browse files
committed
Unbreak my heart
1 parent 7f2f950 commit a681871

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fec list --rss
4242
To load the most recent five filings from the FEC's RSS feed, run:
4343

4444
```bash
45-
for url in $(fec list --rss --headers=false --columns=fec_url --format=tsv | head -n 5); do curl -s $url | fec convert $(echo $url | tr -dc '0-9') --format=psql | psql -v ON_ERROR_STOP=on --single-transaction; done
45+
for url in $(fec list --rss --headers=false --columns=fec_url --format=tsv | head -n 5); do FILING_ID=$(echo $url | tr -dc '0-9'); curl -s "https://docquery.fec.gov/dcdev/posted/"$FILING_ID".fec" | fec convert $FILING_ID --format=psql | psql -v ON_ERROR_STOP=on --single-transaction; done
4646
```
4747

4848
To get just a summary line as JSON:

commands/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fec = require('../');
22

33
module.exports = {
4-
command: 'convert',
4+
command: 'convert [filing_id]',
55
describe:
66
'Pipe in an .fec file to convert it to newline-delimited JSON or psql COPY commands.',
77
builder(yargs) {

commands/list.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
format: {
2323
type: 'string',
2424
default: 'tsv',
25-
choices: ['table','ndjson','json','csv','tsv'],
25+
choices: ['ndjson','csv','tsv'], // 'json', 'table'
2626
describe: 'choose output format'
2727
},
2828
headers: {
@@ -33,13 +33,13 @@ module.exports = {
3333
columns: {
3434
type: 'string',
3535
describe: 'choose columns to show'
36-
},
36+
}/*,
3737
columnLength: {
3838
type: 'integer',
3939
default: 30,
4040
describe:
4141
'how many characters to show in each table cell'
42-
}
42+
}*/
4343
},
4444
handler: async options => {
4545
if (!options.rss && !options.key) {

lib/format.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ module.exports = (stream, format, columns, headers = true, maxLength = 30) => {
1717
*/
1818

1919
switch (format) {
20+
/*
2021
case 'json':
2122
let initial = true;
2223
2324
return stream.pipe(
2425
through2(
2526
{ objectMode: true },
26-
function(row, enc, next) {
27+
function (row, enc, next) {
2728
if (initial) {
2829
this.push('{"rows":');
2930
}
@@ -32,16 +33,16 @@ module.exports = (stream, format, columns, headers = true, maxLength = 30) => {
3233
3334
next();
3435
},
35-
function() {
36+
function () {
3637
this.push(']}');
3738
3839
cb();
3940
}
4041
)
41-
);
42+
);*/
4243
case 'ndjson':
4344
return stream.pipe(
44-
through2.obj((row, enc, next) => {
45+
through2.obj(function (row, enc, next) {
4546
this.push(`${JSON.stringify(row)}\n`);
4647

4748
next();
@@ -80,12 +81,12 @@ module.exports = (stream, format, columns, headers = true, maxLength = 30) => {
8081
headers,
8182
delimiter: (format == 'tsv' ? '\t' : ',')
8283
})
83-
.transform(row => Object.assign({}, ...columns.map(prop => ({[prop]: row[prop]}))));
84+
.transform(row => columns ? Object.assign({}, ...columns.map(prop => ({[prop]: row[prop]}))) : row);
8485

8586
return stream.pipe(formatStream);
8687
default:
8788
throw new Error(
88-
'Invalid format specified, options are: table, ndjson, csv'
89+
'Invalid format specified, options are: ndjson, tsv csv' // table,
8990
);
9091
}
9192
};

lib/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ const models = require('@publici/fec-model')({
33
});
44

55
module.exports = (options) => {
6-
return models.sync();
6+
return models.sync(() => {});
77
}

0 commit comments

Comments
 (0)