From b38a54a3c3f83039a236ec1ddfccbc6040daee77 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 25 Jul 2021 20:37:19 -0500 Subject: [PATCH] General commit --- docker-compose.yml | 19 ++++++++++++++++++- frontend/Dockerfile | 2 +- frontend/src/setupProxy.js | 8 ++++++++ server/Dockerfile | 4 +--- server/app.js | 27 ++++++++++++++++----------- server2 | 1 + 6 files changed, 45 insertions(+), 16 deletions(-) create mode 160000 server2 diff --git a/docker-compose.yml b/docker-compose.yml index 2cb1c73..081e450 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,23 @@ services: options: max-size: "1m" max-file: "3" + + server2: + build: server2 + depends_on: + - postgres + ports: + - "4504:4504" + working_dir: /server2 + volumes: + - ./server2:/server2 + env_file: + - ./server/.env.twitter + logging: + options: + max-size: "1m" + max-file: "3" + imgparser: build: imgparser @@ -47,7 +64,7 @@ services: options: max-size: "1m" max-file: "3" - + frontend: build: context: frontend diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b3910ea..a3983bf 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -9,7 +9,7 @@ ENV PATH /app/node_modules/.bin:$PATH COPY . /app -RUN npm install --silent +RUN npm install -y --silent RUN npm rebuild node-sass CMD ["npm", "start"] \ No newline at end of file diff --git a/frontend/src/setupProxy.js b/frontend/src/setupProxy.js index e4b9eac..ec9cd5b 100644 --- a/frontend/src/setupProxy.js +++ b/frontend/src/setupProxy.js @@ -8,6 +8,14 @@ module.exports = function(app) { changeOrigin: true, }) );*/ + + app.use( + "/ngsplanner", + createProxyMiddleware({ + target: 'https://server2:4504', + changeOrigin: true, + }) + ); app.use( "/ev", createProxyMiddleware({ diff --git a/server/Dockerfile b/server/Dockerfile index 435f572..d8e6ef2 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -54,8 +54,6 @@ ENV JAVA_HOME=/opt/java/openjdk \ RUN apt-get update && \ apt-get install -y ffmpeg && \ apt-get clean; - -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ @@ -71,7 +69,7 @@ RUN yarn global add nodemon # update RUN apt-get update # install curl -RUN apt-get install curl +RUN apt-get install -y curl # get install script and pass it to execute: RUN curl -sL https://deb.nodesource.com/setup_12.x | bash # and install node diff --git a/server/app.js b/server/app.js index 9292ce7..4440acc 100644 --- a/server/app.js +++ b/server/app.js @@ -1,4 +1,4 @@ - const express = require('express') +const express = require('express') const axios = require('axios') const twitchStreams = require('twitch-get-stream') const app = express() @@ -1189,10 +1189,10 @@ app.post('/streaminfo/:id',function (req,res){ } }) -var lastscores={} -const EVENTID=23; -var EVENTSTART=moment('2021-06-28 03:00:00+00'); -var EVENTEND=moment('2021-07-06 11:59:59+00'); +var lastscores_JP={} +const EVENTID=26; +var EVENTSTART=moment('2021-07-25 03:00:00+00'); +var EVENTEND=moment('2021-07-29 11:59:59+00'); var lastscores_EN={} const EVENTID_EN=23; @@ -1206,9 +1206,13 @@ app.get("/helpmetestwithoutbreakingshit", (req,res) => { app.post('/eventsubmit',function(req,res) { - lastscores={} + const lastscores = req.query.en ? lastscores_EN: lastscores_JP; function submit() { - lastscores[req.body.rank]=Number(req.body.points) + if (req.query.en) { + lastscores_EN[req.body.rank]=Number(req.body.points) + } else { + lastscores_JP[req.body.rank]=Number(req.body.points) + } db.query("insert into "+(req.query.en?"en_":"")+"eventdata(eventid,rank,date,name,description,points) values($1,$2,$3,$4,$5,$6) returning *;", [req.body.eventid,req.body.rank,req.body.date?req.body.date:req.body.fin?moment(EVENTEND).add(5,'minutes').format("YYYY-MM-DD HH:mm:ssZ"):new Date(),req.body.name,req.body.description,req.body.points]) .then((data)=>{ @@ -1280,10 +1284,6 @@ app.post('/eventsubmit',function(req,res) { db.query('select distinct on (rank) rank,eventid,date,name,description,points,difference from (select lead(points) over (partition by rank order by rank,date desc)-points difference,* from '+(req.query.en?"en_":"")+'eventdata where eventid='+EVENTID+' order by rank,date desc)t order by rank,date desc') .then((data) => { - if (data.rows.length>0) { - data.rows.map((row)=>{lastscores[row.rank]=row.points}) - - } if (!lastscores[req.body.rank] || (/*FurtherTierIsOkay(req.body.rank,lastscores,req.body.points)&&*/lastscores[req.body.rank]0) { + data.rows.map((row)=>{lastscores[row.rank]=row.points}) + + } } ) }) @@ -1891,6 +1895,7 @@ app.get('/eventdata/t50',function(req,res){ app.get('/eventdata/t20',function(req,res){ var eventinfo = [] + var eventinfo_en = [] if (req.query.date&&req.query.rank) { db.query('select * from '+(req.query.en?"en_":"")+'eventdata where date<=$1 and rank=$2 and eventid=$3 order by date desc limit 1;',[req.query.date,req.query.rank,req.query.eventid]) .then((data)=>{ diff --git a/server2 b/server2 new file mode 160000 index 0000000..2dcbc47 --- /dev/null +++ b/server2 @@ -0,0 +1 @@ +Subproject commit 2dcbc472eca5d33831722d176d39a2758b652c35