From 4f3aa180a0dab8ef14e4982b574c59df2b922e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Thu, 20 Oct 2022 13:38:33 +0800 Subject: [PATCH] bugfix --- netease_music/sql/statistic.sql | 2 +- netease_music/src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netease_music/sql/statistic.sql b/netease_music/sql/statistic.sql index a23c34f..00ea9fe 100644 --- a/netease_music/sql/statistic.sql +++ b/netease_music/sql/statistic.sql @@ -1,8 +1,8 @@ INSERT INTO analysis (`key`, `value`) VALUES ('songCount', (SELECT count(*) as count FROM song) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); INSERT INTO analysis (`key`, `value`) VALUES ('songWaiting', (SELECT count(DISTINCT song_id) AS count -INSERT INTO analysis (`key`, `value`) VALUES ('playlistCount', (SELECT count(*) AS count FROM playlist) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); FROM ( SELECT song_id FROM song_artist_relation UNION SELECT song_id FROM song_album_relation ) t_tmp WHERE song_id NOT IN ( SELECT song_id FROM song )) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); +INSERT INTO analysis (`key`, `value`) VALUES ('playlistCount', (SELECT count(*) AS count FROM playlist) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); INSERT INTO analysis (`key`, `value`) VALUES ('albumCount', (SELECT count(*) as count FROM album) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); INSERT INTO analysis (`key`, `value`) VALUES ('albumWaiting', (SELECT count( DISTINCT album_id ) as count FROM song_album_relation WHERE album_id NOT IN ( SELECT album_id FROM album )) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); INSERT INTO analysis (`key`, `value`) VALUES ('artistCount', (SELECT count(*) AS count FROM artist) ) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`); diff --git a/netease_music/src/index.js b/netease_music/src/index.js index b13d412..e8d24c4 100644 --- a/netease_music/src/index.js +++ b/netease_music/src/index.js @@ -156,7 +156,7 @@ async function watch() { let result = await dbUtils.query(`SELECT \`value\` as count FROM analysis WHERE \`key\`='${sql.name}'`); let sqlTimeSpent = Date.now() - sqlStartTime; sqlsTimeSpent += sqlTimeSpent; - newWatchParam[sql.name] = result[0].count; + newWatchParam[sql.name] = result[0]?.count; console.log(`query ${sql.name} finished.\tspend time: ${sqlTimeSpent}ms (${(sqlTimeSpent / 1000).toFixed(2)}s),\tcount: ${newWatchParam[sql.name]}`); resolve(); }));