From ad48a9ab06617b98ccab9769032bf44fec31b8ec Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 24 Jul 2020 20:45:19 +0800 Subject: [PATCH 1/2] Fixed empty PV issue. --- assets/js/_utils/pageviews.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/assets/js/_utils/pageviews.js b/assets/js/_utils/pageviews.js index 2b34d19..f787f0b 100644 --- a/assets/js/_utils/pageviews.js +++ b/assets/js/_utils/pageviews.js @@ -26,11 +26,13 @@ function countUp(min, max, destId) { function countPV(path, rows) { var count = 0; - for (var i = 0; i < rows.length; ++i) { - var gaPath = rows[i][0]; - if (gaPath == path) { /* path format see: site.permalink */ - count += parseInt(rows[i][1]); - break; + if (rows !== undefined ) { + for (var i = 0; i < rows.length; ++i) { + var gaPath = rows[i][0]; + if (gaPath == path) { /* path format see: site.permalink */ + count += parseInt(rows[i][1]); + break; + } } } @@ -59,7 +61,7 @@ function displayPageviews(data) { } var hasInit = getInitStatus(); - var rows = data.rows; + var rows = data.rows; /* could be undefined */ if ($("#post-list").length > 0) { /* the Home page */ $(".post-preview").each(function() { From a624b9a4722f5ed8f33fa3826a6a0ccf547e6d71 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 25 Jul 2020 00:49:13 +0800 Subject: [PATCH 2/2] Update pv fetching tool. --- tools/publish.sh | 2 -- tools/pv.sh | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/publish.sh b/tools/publish.sh index 4917d9f..a794f75 100755 --- a/tools/publish.sh +++ b/tools/publish.sh @@ -29,8 +29,6 @@ check_status() { update_files() { bash _scripts/sh/create_pages.sh bash _scripts/sh/dump_lastmod.sh - - find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf } diff --git a/tools/pv.sh b/tools/pv.sh index 98f73ba..cd45992 100755 --- a/tools/pv.sh +++ b/tools/pv.sh @@ -16,10 +16,11 @@ set -eu WORK_DIR=$(dirname $(dirname $(realpath "$0"))) -URL_FILE=${WORK_DIR}/assets/data/proxy.json -PV_CACHE=${WORK_DIR}/assets/data/pageviews.json +URL_FILE=${WORK_DIR}/_config.yml +PV_CACHE=${WORK_DIR}/assets/js/data/pageviews.json - -PROXY_URL=$(jq -r '.proxyUrl' $URL_FILE) +PROXY_URL=$(grep "proxy_endpoint:" $URL_FILE | sed "s/.*: '//g;s/'.*//") wget $PROXY_URL -O $PV_CACHE + +echo "ls $PV_CACHE" \ No newline at end of file