Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: x-team/GamesHQ-API
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.6.1
Choose a base ref
...
head repository: x-team/GamesHQ-API
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 13 commits
  • 11 files changed
  • 3 contributors

Commits on Mar 22, 2023

  1. Add missing migrations

    ccmoralesj committed Mar 22, 2023
    Copy the full SHA
    9d50929 View commit details
  2. Merge pull request #71 from x-team/main

    Merge main into Dev
    ccmoralesj authored Mar 22, 2023
    Copy the full SHA
    998608f View commit details
  3. Merge pull request #72 from x-team/GAMESHQ_New-Scoreboard

    Add missing migrations
    ccmoralesj authored Mar 22, 2023
    Copy the full SHA
    2f2bd0f View commit details
  4. Merge pull request #73 from x-team/develop

    Merge Main For missing migrations
    ccmoralesj authored Mar 22, 2023
    Copy the full SHA
    d96dab0 View commit details

Commits on Mar 23, 2023

  1. Copy the full SHA
    f5a7a31 View commit details
  2. Copy the full SHA
    48ec376 View commit details
  3. Merge pull request #74 from x-team/GamesHQ_Tower-scoreboard-hotfix

    Games HQ Tower Statisctis update
    ccmoralesj authored Mar 23, 2023
    Copy the full SHA
    353e106 View commit details
  4. Merge pull request #75 from x-team/develop

    Merge TowerStatistics updates
    ccmoralesj authored Mar 23, 2023
    Copy the full SHA
    b5f8cff View commit details
  5. Copy the full SHA
    14b5e57 View commit details

Commits on Mar 24, 2023

  1. Merge pull request #76 from x-team/XHQ-4387-performance-issues-with-t…

    …he-arena-on-games-hq-api-repository
    
    🪄 [XHQ-4387] Add acknowledgeSlackResponse to Slack methods
    ccmoralesj authored Mar 24, 2023
    Copy the full SHA
    6777255 View commit details
  2. Merge pull request #77 from x-team/develop

    Merge developinto main
    ccmoralesj authored Mar 24, 2023
    Copy the full SHA
    28db748 View commit details

Commits on Oct 25, 2024

  1. Dockerfile improvements

    marcelomilera committed Oct 25, 2024
    Copy the full SHA
    7c31dd6 View commit details

Commits on Oct 29, 2024

  1. Merge pull request #83 from x-team/CORE-2617-multi-stage-docker-build

    Dockerfile improvements
    marcelomilera authored Oct 29, 2024
    Copy the full SHA
    1ada62e View commit details
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist
Dockerfile
docker-compose*.yml
*.log
.git
.coverage
buildspec*.yml
35 changes: 20 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
FROM node:16-alpine
ENV AWS_CLI_VERSION 1.15.47
FROM node:16-alpine AS base

ENV AWS_CLI_VERSION=1.15.47

WORKDIR /app

#copy all the app files
COPY . .
# Install packages for aws-env
RUN apk add --no-cache build-base rsync git python3 py-pip py-setuptools groff less openssl ca-certificates bash \
&& pip --no-cache-dir install awscli==${AWS_CLI_VERSION} \
&& wget https://github.com/Droplr/aws-env/raw/master/bin/aws-env-linux-amd64 -O /bin/aws-env \
&& chmod +x /bin/aws-env \
&& rm -rf /var/cache/apk/*

RUN apk --no-cache update
FROM base AS build

RUN apk add --no-cache build-base rsync git
# Copy only package.json and package-lock.json first to cache npm install step
COPY package*.json ./

#install packages for aws-env
RUN apk add --no-cache python3 py-pip py-setuptools groff less openssl ca-certificates bash && \
pip --no-cache-dir install awscli==${AWS_CLI_VERSION} && \
rm -rf /var/cache/apk/*
# Install dependencies
RUN npm install

#Download aws-env
RUN wget https://github.com/Droplr/aws-env/raw/master/bin/aws-env-linux-amd64 -O /bin/aws-env && chmod +x /bin/aws-env
# Copy the rest of the app files
COPY . .

#Install dependencies and build
RUN npm install && npm run build
# Build the app
RUN npm run build

CMD eval $(aws-env) && npm start
CMD eval $(aws-env) && npm start
Original file line number Diff line number Diff line change
@@ -106,6 +106,7 @@ export async function huntRaiders(
await updateLastHealth(
towerFloor?._towerGameId ?? ZERO,
randomTargetRaider._userId,
towerFloor?.number ?? ZERO,
lastHealth,
transaction
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { QueryInterface, Sequelize } from 'sequelize';
import { DataTypes } from 'sequelize';

interface SequelizeContext {
context: {
queryInterface: QueryInterface;
Sequelize: Sequelize;
};
}

module.exports = {
async up({ context: { queryInterface } }: SequelizeContext) {
return queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn(
'TowerStatistics',
'lastFloorVisited',
{
type: DataTypes.INTEGER,
defaultValue: 0,
},
{ transaction }
);
});
},

async down({ context: { queryInterface } }: SequelizeContext) {
return queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn('TowerStatistics', 'lastFloorVisited', { transaction });
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { QueryInterface, Sequelize } from 'sequelize';
import { DataTypes } from 'sequelize';

interface SequelizeContext {
context: {
queryInterface: QueryInterface;
Sequelize: Sequelize;
};
}

module.exports = {
async up({ context: { queryInterface } }: SequelizeContext) {
return queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn(
'TowerStatistics',
'lastHealth',
{
type: DataTypes.INTEGER,
defaultValue: 100,
},
{ transaction }
);
await queryInterface.addColumn(
'TowerStatistics',
'perks',
{
type: DataTypes.INTEGER,
defaultValue: 0,
},
{ transaction }
);
});
},

async down({ context: { queryInterface } }: SequelizeContext) {
return queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn('TowerStatistics', 'lastHealth', { transaction });
await queryInterface.removeColumn('TowerStatistics', 'perks', { transaction });
});
},
};
2 changes: 1 addition & 1 deletion src/models/TowerRoundAction.ts
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@ export async function findRoundAction(
{ raiderId = null, enemyId = null, roundId }: RoundActionKey,
transaction?: Transaction
) {
let mutableWhereQuery: OptionalWhereParams = {
const mutableWhereQuery: OptionalWhereParams = {
_towerRoundId: roundId,
};
if (raiderId) {
16 changes: 10 additions & 6 deletions src/models/TowerStatistics.ts
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ import {

import { ONE, ZERO } from '../games/consts/global';

import { User, TowerGame, Perk, PerkInventory } from '.';
import type { Perk, PerkInventory } from '.';
import { User, TowerGame } from '.';

interface TowerStatisticsAttributes {
attempts: number;
@@ -142,7 +143,9 @@ export async function updateTowerAsCompleted(
if (towerStats) {
const perksNumber = calculatePerkNumber(perks);
await towerStats.increment({ completed: 1 }, { transaction });
towerStats.lastFloorVisited = lastFloorVisited;
if (lastFloorVisited >= towerStats.lastFloorVisited) {
towerStats.lastFloorVisited = lastFloorVisited;
}
towerStats.perks = perksNumber;
await towerStats.save({ transaction });
}
@@ -186,7 +189,9 @@ export async function updateTowerAttempts(
if (towerStats) {
const perksNumber = calculatePerkNumber(perks);
await towerStats.increment({ attempts: 1 }, { transaction });
towerStats.lastFloorVisited = lastFloorVisited;
if (lastFloorVisited >= towerStats.lastFloorVisited) {
towerStats.lastFloorVisited = lastFloorVisited;
}
towerStats.perks = perksNumber;
await towerStats.save({ transaction });
}
@@ -195,6 +200,7 @@ export async function updateTowerAttempts(
export async function updateLastHealth(
gameId: number,
userId: number,
lastFloorVisited: number,
lastHealth: number,
transaction?: Transaction
) {
@@ -205,9 +211,7 @@ export async function updateLastHealth(
},
transaction,
});
if (towerStats) {
console.log('============================================');
console.log('Here ', lastHealth);
if (towerStats && lastFloorVisited >= towerStats.lastFloorVisited) {
towerStats.lastHealth = lastHealth;
await towerStats.save({ transaction });
}
Original file line number Diff line number Diff line change
@@ -77,11 +77,11 @@ type IAddFloorPayload = {
};

export const addEnemyToFloorHandler: Lifecycle.Method = async (_request, h) => {
const floorId = parseInt(_request.params.floorId);
const floorNumber = parseInt(_request.params.floorNumber);
const { payload } = _request;
const { enemyIds } = payload as IAddEnemiesPayload;

await addEnemies(floorId, enemyIds);
await addEnemies(floorNumber, enemyIds);

return h.response({ success: true }).code(200);
};
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ export const openOrCloseCurrentTowerRoute = {

export const addEnemyToFloorRoute = {
method: 'POST',
path: '/dashboard/admin/floors/{floorId}/addEnemies',
path: '/dashboard/admin/floors/{floorNumber}/addEnemies',
options: {
description: 'Add ',
tags: ['api'],
13 changes: 13 additions & 0 deletions src/modules/slack/slackHandlers.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import { handleTowerBlockAction } from '../../games/tower/actions';
import { handleTowerAction } from '../../games/tower/actions/towerAction';
import { theTowerUnfurlLink } from '../../games/tower/utils';
import { blockKitCompositionImage } from '../../games/utils/generators/slack';
import { acknowledgeSlackResponse } from '../../utils/slack';

import { slackCommandSwitcher } from './utils';

@@ -25,6 +26,10 @@ export const testRouteHandler: Lifecycle.Method = async () => {
};

export const slackCommandHandler: Lifecycle.Method = async (request, _h) => {
// We need to respond to Slack within 3000ms or the action will fail.
// So we acknowledge the request and then handle the command asynchronously.
void acknowledgeSlackResponse();

const slashCommandPayload: SlackSlashCommandPayload = request.pre.slashCommandPayload;
slashCommandPayload.command = slashCommandPayload.command?.replace(
SLACK_COMMAND_STAGING_PREFIX,
@@ -44,6 +49,10 @@ export const slackCommandHandler: Lifecycle.Method = async (request, _h) => {
};

export const arenaSlackActionHandler: Lifecycle.Method = async (request, _h) => {
// We need to respond to Slack within 3000ms or the action will fail.
// So we acknowledge the request and then handle the command asynchronously.
void acknowledgeSlackResponse();

const slackActionPayload = request.pre.slackActionPayload;

try {
@@ -60,6 +69,10 @@ export const arenaSlackActionHandler: Lifecycle.Method = async (request, _h) =>
};

export const towerSlackActionHandler: Lifecycle.Method = async (request, _h) => {
// We need to respond to Slack within 3000ms or the action will fail.
// So we acknowledge the request and then handle the command asynchronously.
void acknowledgeSlackResponse();

const slackActionPayload = request.pre.slackActionPayload;
try {
switch (slackActionPayload.type) {
7 changes: 7 additions & 0 deletions src/utils/slack.ts
Original file line number Diff line number Diff line change
@@ -33,3 +33,10 @@ export function parseEscapedSlackId(slackUser: string) {
return slackUser.replace('@', '');
}
}

// We need to acknowledge the request to Slack within 3 seconds
export function acknowledgeSlackResponse() {
process.nextTick(() => {
return {};
});
}