Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HTTPArchive/almanac.httparchive.org…
Browse files Browse the repository at this point in the history
… into production
  • Loading branch information
tunetheweb committed Mar 19, 2024
2 parents 19a6d1c + 3ddb800 commit 71ac0a6
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 201 deletions.
4 changes: 2 additions & 2 deletions src/config/last_updated.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
},
"/static/js/send-web-vitals.js": {
"date_published": "2021-02-24T00:00:00.000Z",
"date_modified": "2024-02-23T00:00:00.000Z",
"hash": "dbdf76e48652c343c8d368cf130f7928"
"date_modified": "2024-03-19T00:00:00.000Z",
"hash": "894f90d1e739fb10194e73258c7946ec"
},
"/static/js/web-vitals.js": {
"date_published": "2020-11-13T00:00:00.000Z",
Expand Down
254 changes: 88 additions & 166 deletions src/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"node-fetch": "3.3.2",
"node-watch": "0.7.4",
"prettier": "3.2.5",
"puppeteer": "22.2.0",
"puppeteer": "22.5.0",
"rainbow-code": "2.1.7",
"recursive-readdir": "2.2.3",
"run-script-os": "1.1.6",
Expand Down
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flask==3.0.2
flask-talisman==1.1.0
gunicorn==21.2.0
pytest==8.0.1
pytest==8.1.1
pytest-watch==4.2.0
pytest-cov==4.1.0
sqlfluff==1.4.5
53 changes: 28 additions & 25 deletions src/static/js/send-web-vitals.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,35 @@ function sendWebVitals() {
// LoAFs that intersect with the event.
return entry.startTime < (loaf.startTime + loaf.duration) && loaf.startTime < (entry.startTime + entry.duration);
}).forEach(loaf => {
const loafEndTime = loaf.startTime + loaf.duration;
loaf.scripts.forEach(script => {
const totalDuration = script.startTime + script.duration;
if (totalDuration > loafAttribution.debug_loaf_script_total_duration) {
loafAttribution = {
// Stats for the LoAF entry itself.
debug_loaf_entry_start_time: loaf.startTime,
debug_loaf_entry_end_time: loaf.startTime + loaf.duration,
debug_loaf_entry_work_duration: loaf.renderStart ? loaf.renderStart - loaf.startTime : loaf.duration,
debug_loaf_entry_render_duration: loaf.renderStart ? loaf.startTime + loaf.duration - loaf.renderStart : 0,
debug_loaf_entry_total_forced_style_and_layout_duration: loaf.scripts.reduce((sum, script) => sum + script.forcedStyleAndLayoutDuration, 0),
debug_loaf_entry_pre_layout_duration: loaf.styleAndLayoutStart ? loaf.styleAndLayoutStart - loaf.renderStart : 0,
debug_loaf_entry_style_and_layout_duration: loaf.styleAndLayoutStart ? loaf.startTime + loaf.duration - loaf.styleAndLayoutStart : 0,

// Stats for the longest script in the LoAF entry.
debug_loaf_script_total_duration: totalDuration,
debug_loaf_script_compile_duration: script.executionStart - script.startTime,
debug_loaf_script_exec_duration: script.startTime + script.duration - script.executionStart,
debug_loaf_script_invoker: script.invoker,
debug_loaf_script_type: script.invokerType,
debug_loaf_script_source_url: script.sourceURL,
debug_loaf_script_source_function_name: script.sourceFunctionName,
debug_loaf_script_source_char_position: script.sourceCharPosition,

// LoAF metadata.
debug_loaf_meta_length: longAnimationFrames.length,
}
if (script.duration <= loafAttribution.debug_loaf_script_total_duration) {
return;
}
loafAttribution = {
// Stats for the LoAF entry itself.
debug_loaf_entry_start_time: loaf.startTime,
debug_loaf_entry_end_time: loafEndTime,
debug_loaf_entry_work_duration: loaf.renderStart ? loaf.renderStart - loaf.startTime : loaf.duration,
debug_loaf_entry_render_duration: loaf.renderStart ? loafEndTime - loaf.renderStart : 0,
debug_loaf_entry_total_forced_style_and_layout_duration: loaf.scripts.reduce((sum, script) => sum + script.forcedStyleAndLayoutDuration, 0),
debug_loaf_entry_pre_layout_duration: loaf.styleAndLayoutStart ? loaf.styleAndLayoutStart - loaf.renderStart : 0,
debug_loaf_entry_style_and_layout_duration: loaf.styleAndLayoutStart ? loafEndTime - loaf.styleAndLayoutStart : 0,

// Stats for the longest script in the LoAF entry.
debug_loaf_script_total_duration: script.duration,
debug_loaf_script_compile_duration: script.executionStart - script.startTime,
debug_loaf_script_exec_duration: script.startTime + script.duration - script.executionStart,
debug_loaf_script_source: script.sourceLocation || script.invoker || script.name, // TODO: remove after Chrome 123
debug_loaf_script_type: script.invokerType || script.type, // TODO: remove `|| script.type` after Chrome 123
// New in Chrome 122/123 (will be null until then)
debug_loaf_script_invoker: script.invoker,
debug_loaf_script_source_url: script.sourceURL,
debug_loaf_script_source_function_name: script.sourceFunctionName,
debug_loaf_script_source_char_position: script.sourceCharPosition,

// LoAF metadata.
debug_loaf_meta_length: longAnimationFrames.length,
}
});
});
Expand Down
1 change: 1 addition & 0 deletions src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="origin-trial" content="AqqBKXKVFUu6Op5aphalxMRl8CECiZ0BVlee+zWMM1E9R6oLnNQPRIXd5F8gEYxahMwEzEjOYKzA3Nf6jIc08AEAAAB0eyJvcmlnaW4iOiJodHRwczovL2h0dHBhcmNoaXZlLm9yZzo0NDMiLCJmZWF0dXJlIjoiTG9uZ0FuaW1hdGlvbkZyYW1lVGltaW5nIiwiZXhwaXJ5IjoxNzE2OTQwNzk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=">
{% block head %}
<title>{% block title %}The Web Almanac{% endblock %}</title>
<link rel="stylesheet" href="{{ get_versioned_filename('/static/css/normalize.css') }}">
Expand Down
9 changes: 7 additions & 2 deletions src/tools/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function check_continue {
fi
}

if [ ! "$(which pgrep)" ]; then
echo "Need pgrep installed. Try 'brew install proctools'"
exit 1
fi

echo "Beginning the Web Almanac deployment process"

# This script must be run from src directory
Expand Down Expand Up @@ -95,7 +100,7 @@ git status
git pull
git pull origin main

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing existing server to run a fresh version"
pkill -9 python main.py
fi
Expand Down Expand Up @@ -192,7 +197,7 @@ git status
echo "Checking out main branch"
git checkout main

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing server so backgrounded version isn't left there"
pkill -9 -f "python main.py"
fi
Expand Down
13 changes: 9 additions & 4 deletions src/tools/scripts/run_and_test_website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ if [ -d "src" ]; then
cd src
fi

if [ "$(pgrep -f 'python main.py')" ]; then
if [ ! "$(which pgrep)" ]; then
echo "Need pgrep installed. Try 'brew install proctools'"
exit 1
fi

if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing existing server to run a fresh version"
pkill -9 -f "python main.py"
fi

if [ "$(pgrep -f 'node ./tools/generate/chapter_watcher')" ]; then
if [ "$(pgrep -if 'node ./tools/generate/chapter_watcher')" ]; then
echo "Killing existing watcher to run a fresh version"
pkill -9 -f "node ./tools/generate/chapter_watcher"
fi
Expand All @@ -65,7 +70,7 @@ python main.py background &
# Sleep for a couple of seconds to make sure server is up
sleep 2
# Check website is running as won't have got feedback as backgrounded
pgrep -f "python main.py"
pgrep -if "python main.py"

echo "Installing node modules"
npm install
Expand Down Expand Up @@ -98,7 +103,7 @@ if [ "${debug}" == "1" ]; then
echo "Monitoring templates for changes"
npm run watch &

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing server to run a fresh version in debug mode"
pkill -9 -f "python main.py"
fi
Expand Down

0 comments on commit 71ac0a6

Please sign in to comment.