Skip to content

Commit

Permalink
Merge branch 'feature/improve-pv-fetching' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Jul 26, 2020
2 parents b3cf05e + 0ab7c01 commit 65e0ef8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
14 changes: 8 additions & 6 deletions assets/js/_utils/pageviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions tools/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
9 changes: 5 additions & 4 deletions tools/pv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 65e0ef8

Please sign in to comment.