Merge branch 'feature/improve-pv-fetching' into develop

This commit is contained in:
Cotes Chung 2020-07-26 22:25:39 +08:00
commit 4675d42f90
3 changed files with 13 additions and 12 deletions

View file

@ -26,11 +26,13 @@ function countUp(min, max, destId) {
function countPV(path, rows) { function countPV(path, rows) {
var count = 0; var count = 0;
for (var i = 0; i < rows.length; ++i) { if (rows !== undefined ) {
var gaPath = rows[i][0]; for (var i = 0; i < rows.length; ++i) {
if (gaPath == path) { /* path format see: site.permalink */ var gaPath = rows[i][0];
count += parseInt(rows[i][1]); if (gaPath == path) { /* path format see: site.permalink */
break; count += parseInt(rows[i][1]);
break;
}
} }
} }
@ -59,7 +61,7 @@ function displayPageviews(data) {
} }
var hasInit = getInitStatus(); var hasInit = getInitStatus();
var rows = data.rows; var rows = data.rows; /* could be undefined */
if ($("#post-list").length > 0) { /* the Home page */ if ($("#post-list").length > 0) { /* the Home page */
$(".post-preview").each(function() { $(".post-preview").each(function() {

View file

@ -29,8 +29,6 @@ check_status() {
update_files() { update_files() {
bash _scripts/sh/create_pages.sh bash _scripts/sh/create_pages.sh
bash _scripts/sh/dump_lastmod.sh bash _scripts/sh/dump_lastmod.sh
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
} }

View file

@ -16,10 +16,11 @@
set -eu set -eu
WORK_DIR=$(dirname $(dirname $(realpath "$0"))) WORK_DIR=$(dirname $(dirname $(realpath "$0")))
URL_FILE=${WORK_DIR}/assets/data/proxy.json URL_FILE=${WORK_DIR}/_config.yml
PV_CACHE=${WORK_DIR}/assets/data/pageviews.json PV_CACHE=${WORK_DIR}/assets/js/data/pageviews.json
PROXY_URL=$(grep "proxy_endpoint:" $URL_FILE | sed "s/.*: '//g;s/'.*//")
PROXY_URL=$(jq -r '.proxyUrl' $URL_FILE)
wget $PROXY_URL -O $PV_CACHE wget $PROXY_URL -O $PV_CACHE
echo "ls $PV_CACHE"