From fb529794df9eed9f1bd17037402a73a4d269376f Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 11 Sep 2022 13:36:50 +0200 Subject: [PATCH 1/5] update githook --- deployment/githook.sh | 45 ++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/deployment/githook.sh b/deployment/githook.sh index 65bb66d..75d92d1 100755 --- a/deployment/githook.sh +++ b/deployment/githook.sh @@ -30,6 +30,24 @@ npm_reinstall () { npm install } +copy () { + local TARGETDIR="${1}" + local REINSTALL="${2}" + cp -r dist/*.js "${TARGETDIR}/" + cp -r dist/workers "${TARGETDIR}/" + rm -rf "${TARGETDIR}/public/assets" + cp -r dist/public "${TARGETDIR}/" + cp -r dist/captchaFonts "${TARGETDIR}/" + cp -r dist/package.json "${TARGETDIR}/" + cp -r dist/assets.json "${TARGETDIR}/" + cp -r dist/styleassets.json "${TARGETDIR}/" + mkdir -p "${TARGETDIR}/log" + cd "${TARGETDIR}" + [ $REINSTALL -eq 0 ] && npm_reinstall + pm2 start ecosystem.yml + cd - +} + while read oldrev newrev refname do GIT_WORK_TREE="$BUILDDIR" GIT_DIR="${BUILDDIR}/.git" git fetch --all @@ -46,20 +64,10 @@ do [ $DO_REINSTALL -eq 0 ] && npm_reinstall npm run build echo "---RESTARTING CANVAS---" - cp -r dist/*.js "${PFOLDER}/" - cp -r dist/workers "${PFOLDER}/" - rm -rf "${PFOLDER}/public/assets" - cp -r dist/public "${PFOLDER}/" - cp -r dist/captchaFonts "${PFOLDER}/" - cp -r dist/package.json "${PFOLDER}/" - cp -r dist/assets.json "${PFOLDER}/" - cp -r dist/styleassets.json "${PFOLDER}/" - mkdir -p "${PFOLDER}/log" - cd "$PFOLDER" pm2 stop ppfun-server pm2 stop ppfun-backups - [ $DO_REINSTALL -eq 0 ] && npm_reinstall - pm2 start ecosystem.yml + copy "${PFOLDER}" "${DO_REINSTALL}" + cd "$PFOLDER" pm2 start ecosystem-backup.yml else echo "---UPDATING REPO ON DEV SERVER---" @@ -73,17 +81,6 @@ do [ $DO_REINSTALL -eq 0 ] && npm_reinstall nice -n 19 npm run build:dev echo "---RESTARTING CANVAS---" - cp -r dist/*.js "${DEVFOLDER}/" - cp -r dist/workers "${DEVFOLDER}/" - rm -rf "${DEVFOLDER}/public/assets" - cp -r dist/public "${DEVFOLDER}/" - cp -r dist/captchaFonts "${DEVFOLDER}/" - cp -r dist/package.json "${DEVFOLDER}/" - cp -r dist/assets.json "${DEVFOLDER}/" - cp -r dist/styleassets.json "${DEVFOLDER}/" - mkdir -p "${PFOLDER}/log" - cd "$DEVFOLDER" - [ $DO_REINSTALL -eq 0 ] && npm_reinstall - pm2 start ecosystem.yml + copy "${DEVFOLDER}" "${DO_REINSTALL}" fi done From 0a9172d3a7842ed1b95c5543813b8ac577cf7253 Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 11 Sep 2022 13:36:57 +0200 Subject: [PATCH 2/5] cache session middlewares --- src/core/session.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/core/session.js b/src/core/session.js index 334f7cc..6944db4 100644 --- a/src/core/session.js +++ b/src/core/session.js @@ -10,22 +10,27 @@ import { HOUR, COOKIE_SESSION_NAME } from './constants'; import { SESSION_SECRET } from './config'; -export const store = new RedisStore({ client }); +const middlewareStore = {}; export default (req, res, next) => { const domain = getHostFromRequest(req, false, true); - const sess = session({ - name: COOKIE_SESSION_NAME, - store, - secret: SESSION_SECRET, - resave: false, - saveUninitialized: false, - cookie: { - domain, - httpOnly: true, - secure: false, - maxAge: 30 * 24 * HOUR, - }, - }); + let sess = middlewareStore[domain]; + if (!sess) { + const store = new RedisStore({ client }); + sess = session({ + name: COOKIE_SESSION_NAME, + store, + secret: SESSION_SECRET, + resave: false, + saveUninitialized: false, + cookie: { + domain, + httpOnly: true, + secure: false, + maxAge: 30 * 24 * HOUR, + }, + }); + middlewareStore[domain] = sess; + } return sess(req, res, next); }; From 7236e1c3c65b5bd657a5089f7aa20f0372b73197 Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 11 Sep 2022 18:47:02 +0200 Subject: [PATCH 3/5] pixel counters are never null in the database --- src/core/ranking.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ranking.js b/src/core/ranking.js index 30ed66f..d95e6d4 100644 --- a/src/core/ranking.js +++ b/src/core/ranking.js @@ -38,11 +38,11 @@ class Ranks { // recalculate ranking column await sequelize.query( // eslint-disable-next-line max-len - 'SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) WHERE totalPixels IS NOT NULL ORDER BY totalPixels DESC;', + 'SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) ORDER BY totalPixels DESC;', ); await sequelize.query( // eslint-disable-next-line max-len - 'SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) WHERE dailyTotalPixels IS NOT NULL ORDER BY dailyTotalPixels DESC;', + 'SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) ORDER BY dailyTotalPixels DESC;', ); } else { logger.info('Get pixel rankings from SQL'); From 097926579f993cf07d96a0e8b7563b1891f97204 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 12 Sep 2022 00:37:16 +0200 Subject: [PATCH 4/5] add chirstmas button --- src/components/App.jsx | 2 + src/components/buttons/ChristmasButton.jsx | 61 ++ src/ui/snow.js | 669 +++++++++++++++++++++ 3 files changed, 732 insertions(+) create mode 100644 src/components/buttons/ChristmasButton.jsx create mode 100644 src/ui/snow.js diff --git a/src/components/App.jsx b/src/components/App.jsx index 75256a6..50ad361 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -11,6 +11,7 @@ import Style from './Style'; import CoordinatesBox from './CoordinatesBox'; import CanvasSwitchButton from './buttons/CanvasSwitchButton'; import OnlineBox from './OnlineBox'; +import ChristmasButton from './buttons/ChristmasButton'; import ChatButton from './buttons/ChatButton'; import Menu from './Menu'; import UI from './UI'; @@ -23,6 +24,7 @@ const App = () => ( <>