Validate first key item and skip to insert items
This commit is contained in:
@@ -299,6 +299,7 @@ extension KissConsole {
|
|||||||
let db = try KissDB(directory: yearDbPath)
|
let db = try KissDB(directory: yearDbPath)
|
||||||
try db.begin()
|
try db.begin()
|
||||||
|
|
||||||
|
var isFirstValidated = false
|
||||||
for candle in candles {
|
for candle in candles {
|
||||||
if trimAfterMarket {
|
if trimAfterMarket {
|
||||||
guard candle.isValidInMarketTime else {
|
guard candle.isValidInMarketTime else {
|
||||||
@@ -306,6 +307,16 @@ extension KissConsole {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let candleData = try CandleData(candle: candle)
|
let candleData = try CandleData(candle: candle)
|
||||||
|
|
||||||
|
if !isFirstValidated {
|
||||||
|
try db.selectData(key: candleData.key, into: { dataItem -> Bool in
|
||||||
|
if dataItem.key == candleData.key {
|
||||||
|
isFirstValidated = true
|
||||||
|
print("Skipped by first validation: \(csvFile)")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
let item = KissDB.DataItem(key: candleData.key, value: candleData.data)
|
let item = KissDB.DataItem(key: candleData.key, value: candleData.data)
|
||||||
try db.insertData(item: item)
|
try db.insertData(item: item)
|
||||||
|
|
||||||
|
|||||||
Submodule libraries/KissMeme updated: feb81bf03a...5ae9afdfa2
Reference in New Issue
Block a user