Skip to content

Commit

Permalink
Merge pull request #745 from zurichat/staging
Browse files Browse the repository at this point in the history
Moving staging to main for production release
  • Loading branch information
NdubuisiJr authored Nov 3, 2021
2 parents afa401f + d9070c6 commit 4a6939c
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ dist

# TernJS port file
.tern-port
backend/package-lock.json
3 changes: 2 additions & 1 deletion backend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rules": {
"no-console": "off",
"implicit-arrow-linebreak": "off",
"no-nested-ternary": "off"
"no-nested-ternary": "off",
"linebreak-style": "off"
}
}
2 changes: 1 addition & 1 deletion backend/src/controllers/game.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class GameController {

await centrifugoController.publishToSideBar(
this.organisation_id,
user_id,
gameDBData.data.owner.user_id,
sidebar_update_payload_owner,
);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/info.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class InformationController {
this.organisation_id = req.body.organisation_id;
this.user_id = req.body.user_id;

const url = `https://api.zuri.chat/organizations/${this.Authorizationorganisation_id}/plugins`;
const url = `https://api.zuri.chat/organizations/${this.organisation_id}/plugins`;

await axios.post(
url,
Expand Down
26 changes: 26 additions & 0 deletions backend/src/utils/gameWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
const { parentPort } = require('worker_threads');
const globalTime = require('global-time');
const DatabaseConnection = require('../db/database.helper');
const centrifugoController = require('../controllers/centrifugo.controller');
const InformationController = require('../controllers/info.controller');

const orgId = process.argv[2];
const gameId = process.argv[3];
Expand All @@ -20,6 +22,30 @@ const timer = setInterval(async () => {
if (time - game.data.modifiedAt > 5 * 60 * 1000) {
await gameRepo.delete(game.data._id, game.data);
parentPort.postMessage(`${orgId}:${gameId}`);

// collect sidebar info for game user
const sidebarUpdatePayloadOwner = await InformationController.sideBarInfo(
orgId,
game.data.owner.user_id,
);
// publishing collected sidebar info of both owner and opponent
await centrifugoController.publishToSideBar(
orgId,
game.data.owner.user_id,
sidebarUpdatePayloadOwner,
);

if (game.data.opponent != null) {
const sidebarUpdatePayloadOpponent = await InformationController.sideBarInfo(
orgId,
game.data.opponent.user_id,
);
await centrifugoController.publishToSideBar(
orgId,
game.data.opponent.user_id,
sidebarUpdatePayloadOpponent,
);
}
}
}, 5 * 60 * 1000);

Expand Down
8 changes: 4 additions & 4 deletions client/src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"react-dom": "//cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.production.min.js",
"@zuri/root-config": "//chess.zuri.chat/zuri-root-config.js",
"@zuri/zuri-plugin-chessboard": "//chess.zuri.chat/zuri-zuri-plugin-chessboard.js",
"@zuri/utilities": "//zuri.chat/zuri-utilities.js",
"@zuri/plugin-header": "//zuri.chat/zuri-plugin-header.js"
"@zuri/utilities": "//staging.zuri.chat/zuri-utilities.js",
"@zuri/plugin-header": "//staging.zuri.chat/zuri-plugin-header.js"
}
}
</script>
Expand All @@ -57,8 +57,8 @@
"@single-spa/welcome": "//unpkg.com/single-spa-welcome/dist/single-spa-welcome.js",
"@zuri/root-config": "//chess.zuri.chat/zuri-root-config.js",
"@zuri/zuri-plugin-chessboard": "//chess.zuri.chat/zuri-zuri-plugin-chessboard.js",
"@zuri/utilities": "//zuri.chat/zuri-utilities.js",
"@zuri/plugin-header": "//zuri.chat/zuri-plugin-header.js"
"@zuri/utilities": "//staging.zuri.chat/zuri-utilities.js",
"@zuri/plugin-header": "//staging.zuri.chat/zuri-plugin-header.js"
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions frontend/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ react-dom
https://cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.production.min.js

@zuri/utilities
https://zuri.chat/zuri-utilities.js
https://staging.zuri.chat/zuri-utilities.js

@zuri/plugin-header
https://zuri.chat/zuri-plugin-header.js
https://staging.zuri.chat/zuri-plugin-header.js
8 changes: 6 additions & 2 deletions frontend/src/components/ChessBoardBorder/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React from 'react';
// import { keyframes } from 'styled-components';
// Import CSS for this page
// import "./chessboardborder.css";

// Import style for this page
import { AlphabetSection, NumberSection } from './styles';

let count = 0;
const getID = () => count++;

const Alphabets = () => (
<AlphabetSection>
<div className="wrapper">
{[...'abcdefgh'].map((item) => (
<div className="letters" key={new Date().toISOString()}>
<div className="letters" key={getID()}>
{item.toUpperCase()}
</div>
))}
Expand All @@ -21,7 +25,7 @@ const Numbers = () => (
<NumberSection>
<div className="wrapper">
{[...'87654321'].map((item) => (
<div className="digit" key={new Date().toISOString()}>
<div className="digit" key={getID()}>
{item}
</div>
))}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/SpectatorSideBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import close from '../../assets/comment/close.svg';
// Import Adapters
import { sendComment } from '../../adapters/comments';

// Import Utilities
import mapTimeStamp from './mapTimeStamp';

// (lekandev) Commented it out
// import style-components
// import {
Expand Down Expand Up @@ -141,7 +144,7 @@ const SpectatorSideBar = ({ type, gameData }) => {
<img className={styles.specAvi} src={image_url} alt="avi" />
<div className={styles.specInfo}>
<h2 className={styles.spectatorName}>{user_name}</h2>
<p className={styles['time-muted']}>{timestamp}</p>
<p className={styles['time-muted']}>{mapTimeStamp(timestamp)}</p>
</div>
</div>
<div className={styles.specNameTime}>
Expand Down
33 changes: 33 additions & 0 deletions frontend/src/components/SpectatorSideBar/mapTimeStamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export default (timeStamp) => {
let mappedTimeStamp = '';
const [date, time, suffix] = timeStamp.split(' ');
const [month, day, year] = date.split('/');
const [hr, min, sec] = time.split(':');
const currentDate = new Date(
new Date().toLocaleString('en-US', {
timeZone: 'UTC',
}),
);
const commentDate = suffix === 'PM'
? new Date(year.replace(',', ''), Number(month) - 1, day, Number(hr) + 12, min, sec)
: new Date(year.replace(',', ''), Number(month) - 1, day, hr, min, sec);
const diff = currentDate - commentDate;
const diffObj = {
second: diff / 1000,
minute: diff / 1000 / 60,
hour: diff / 1000 / 60 / 60,
day: diff / 1000 / 60 / 60 / 24,
week: diff / 1000 / 60 / 60 / 24 / 7,
month: diff / 1000 / 60 / 60 / 24 / 7 / 4,
year: diff / 1000 / 60 / 60 / 24 / 7 / 4 / 12,
};
Object.keys(diffObj).forEach((key) => {
const value = Math.floor(diffObj[key]);
if (value === 1) {
mappedTimeStamp = `${value} ${key} ago`;
} else if (value > 1) {
mappedTimeStamp = `${value} ${key}s ago`;
}
});
return mappedTimeStamp;
};

0 comments on commit 4a6939c

Please sign in to comment.