John Wilson
10/20/2022, 9:56 PMScott Steinbeck
10/20/2022, 9:59 PMJohn Wilson
10/20/2022, 10:00 PMJohn Wilson
10/20/2022, 10:00 PMScott Steinbeck
10/20/2022, 10:02 PMJohn Wilson
10/20/2022, 10:03 PMvar snort = qb
.setReturnFormat( "query" )
.from( "accounts a" )
.join( "accounts_holdings h", "a.id", "h.accountID" )
.when( rc.keyExists( "accountID" ), ( q ) => {
q.andWhere( "a.id", rc.accountID );
} )
.when( rc.keyExists( "bTaxable" ), ( q ) => {
q.andWhere( "a.bTaxable", rc.bTaxable );
} )
.selectRaw( "a.portfolioCode,ticker,format(purchaseDate,'yyyy-MM-dd'),costbasis,lotID,'TRUE','TRUE',0" )
.get()
var cols = snort.columnArray()
snort = snort.reduce( ( o, row ) => {
return o & cols
.map( ( col, i ) => {
return row[ col ]
} )
.toList() & chr( 10 );
}, "" )
Scott Steinbeck
10/20/2022, 10:05 PMJohn Wilson
10/20/2022, 10:06 PMAdam Cameron
but need to return directly from an api at scaleWhat does that mean?
Adam Cameron
Scott Steinbeck
10/20/2022, 10:15 PMJohn Wilson
10/20/2022, 10:15 PMScott Steinbeck
10/20/2022, 10:16 PMvar columns = ["id","title"];
csvData = sortedNews.map((row) =>{
var rowData = [];
columns.each((colName) => {
rowData.append(row[colName]);
})
return rowData.toList(",")
},true,10);
dump(arrayToList(csvData,"#chr(10)##chr(13)#"))
John Wilson
10/20/2022, 10:17 PMScott Steinbeck
10/20/2022, 10:17 PMScott Steinbeck
10/20/2022, 10:21 PMeach
because there is a breaking point (depending on how many columns you have) of speed vs. spinning up threads. so on 10-15 columns probably not going to be faster with asyncJohn Wilson
10/20/2022, 10:22 PMvar cols = [
"portfolioCode",
"ticker",
"purchaseDate",
"costbasis",
"lotID",
"isHeldShort",
"isForceHold",
"penalty"
]
snort = snort
.map( ( row ) => {
return cols
.map( ( col, i ) => {
return row[ col ]
} )
.toList()
}, true )
.toList( chr( 10 ) );
Scott Steinbeck
10/20/2022, 10:22 PM10
is a placeholder for the number of parallel processes so set as necessary for your use caseJohn Wilson
10/20/2022, 10:22 PMJohn Wilson
10/20/2022, 10:23 PMAdam Cameron
John Wilson
10/20/2022, 10:28 PMAdam Cameron
John Wilson
10/20/2022, 10:36 PMAdam Cameron
i
yer not using in that innermost map
, too.John Wilson
10/20/2022, 10:39 PMJohn Wilson
10/20/2022, 10:40 PMAdam Cameron
reduce
is more idiomatic.
Although if performance is a consideration, all the accumulated string building might be slow.John Wilson
10/20/2022, 10:43 PMAdam Cameron
John Wilson
10/20/2022, 10:43 PMsnort.map( ( row ) => cols.map( ( col, i ) => row[ col ] ).toList(), true ).toList( "<br>" );
vs
snort.reduce( ( o, row ) => o & cols.map( ( col ) => row[ col ], true ).toList() & "<br>", "" )
John Wilson
10/20/2022, 10:43 PMAdam Cameron
Adam Cameron
John Wilson
10/20/2022, 10:46 PMAdam Cameron
Michael Schmidt
10/20/2022, 10:46 PMJohn Wilson
10/20/2022, 10:46 PMAdam Cameron
Adam Cameron
Adam Cameron
John Wilson
10/20/2022, 10:48 PMAdam Cameron
Adam Cameron
John Wilson
10/20/2022, 10:48 PMAdam Cameron
John Wilson
10/20/2022, 10:49 PMAdam Cameron
Scott Steinbeck
10/20/2022, 10:49 PMJohn Wilson
10/20/2022, 10:49 PMJohn Wilson
10/20/2022, 10:50 PMScott Steinbeck
10/20/2022, 10:50 PMAdam Cameron
Scott Steinbeck
10/20/2022, 10:50 PMScott Steinbeck
10/20/2022, 10:50 PMJohn Wilson
10/20/2022, 10:51 PMAdam Cameron
John Wilson
10/20/2022, 10:51 PMJohn Wilson
10/20/2022, 10:51 PMAdam Cameron
@Adam Cameron is talking in his sleepFINE. Ciao.
Scott Steinbeck
10/20/2022, 10:52 PMScott Steinbeck
10/20/2022, 10:54 PMScott Steinbeck
10/20/2022, 11:00 PMJohn Wilson
10/20/2022, 11:00 PMJohn Wilson
10/20/2022, 11:01 PMJohn Wilson
10/20/2022, 11:02 PMScott Steinbeck
10/20/2022, 11:26 PMcfsimplicity
10/24/2022, 9:45 AMScott Steinbeck
10/24/2022, 7:01 PMScott Steinbeck
10/24/2022, 7:31 PM.toList()
method.Scott Steinbeck
10/24/2022, 7:32 PMcfsimplicity
10/24/2022, 7:41 PMScott Steinbeck
10/24/2022, 7:42 PMScott Steinbeck
10/24/2022, 7:44 PM.toList()
just creates a string builder