Commit a892a03e authored by ml's avatar ml

Merge remote-tracking branch 'origin/master'

parents a5b9e71b beaf9704
...@@ -22,7 +22,8 @@ let job = schedule.scheduleJob('*/15 * * * * ?', async function () { ...@@ -22,7 +22,8 @@ let job = schedule.scheduleJob('*/15 * * * * ?', async function () {
await syncCoin(); await syncCoin();
running = true; running = true;
logger.info("coinAndPair sync job finish"); logger.info("coinAndPair sync job finish");
} catch (e) { }
catch (e) {
logger.info(e) logger.info(e)
} }
running = false; running = false;
...@@ -33,8 +34,8 @@ const syncPair = async () => { ...@@ -33,8 +34,8 @@ const syncPair = async () => {
let now = new Date(); let now = new Date();
let res = await spotPairs.prototype.findAll({ let res = await spotPairs.prototype.findAll({
where: { where: {
status:1, status: 1,
updatedAt:{[ormDB.Op.lt]:new Date(now.getTime()-10*1000)} // 10秒之前的 updatedAt: { [ormDB.Op.lt]: new Date(now.getTime() - 10 * 1000) } // 10秒之前的
}, },
raw: true raw: true
}) })
...@@ -57,6 +58,8 @@ const syncPair = async () => { ...@@ -57,6 +58,8 @@ const syncPair = async () => {
logger.info(symbol, "sync config success") logger.info(symbol, "sync config success")
} }
} }
} }
...@@ -64,15 +67,15 @@ const syncCoin = async () => { ...@@ -64,15 +67,15 @@ const syncCoin = async () => {
let now = new Date(); let now = new Date();
let res = await coinType.prototype.findAll({ let res = await coinType.prototype.findAll({
where: { where: {
is_main:1, is_main: 1,
main_status:1, main_status: 1,
updatedAt:{[ormDB.Op.lt]:new Date(now.getTime()-10*1000)} // 10秒之前的 updatedAt: { [ormDB.Op.lt]: new Date(now.getTime() - 10 * 1000) } // 10秒之前的
}, },
raw: true raw: true
}) })
for (const coin of res) { for (const coin of res) {
const { general_name:symbol, id } = coin; const { general_name: symbol, id } = coin;
let cfg = await getCoinFromCore(symbol); let cfg = await getCoinFromCore(symbol);
if (cfg) { if (cfg) {
await coinType.prototype.update({ await coinType.prototype.update({
...@@ -84,6 +87,25 @@ const syncCoin = async () => { ...@@ -84,6 +87,25 @@ const syncCoin = async () => {
logger.info(symbol, "sync config success") logger.info(symbol, "sync config success")
} }
} }
// 更新is_main等于0的状态
let dbsyncres = await coinType.prototype.findAll({
attributes: ['general_name','asset_id'],
where: {
is_main: 1,
main_status: 2,
},
raw: true
})
for (const coin of dbsyncres) {
await coinType.prototype.update({ main_status: 2,asset_id:coin.asset_id }, {
where: {
general_name: coin.general_name, is_main: 0, main_status: 0
}
})
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment