Skip to content

Commit

Permalink
update beta deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
bananahampster committed Jan 16, 2024
1 parent 1aa08d2 commit 1461c11
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 14 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# The following script assumes the following:
#
# Depencencies installed on the destination machine: npm, node, pm2, tsc
# * `~/hampalyzer` is this cloned repo in the user's home directory
# * `pm2 start dist/index.js --name hampalyzer` was previously run

name: Deploy Hampalyzer BETA

# Controls when the action will run.
on:
push:
branches: [ db-cleanup, beta ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: deploy script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BETA_SERVER_NAME }}
username: ${{ secrets.DEPLOY_USER }}
password: ${{ secrets.BETA_DEPLOY_PASSWORD }}
script: |
cd ~/hampalyzer
git reset --hard origin/master
git pull origin master
npm install
tsc
cp -rfL ~/hampalyzer/frontend/* -t /var/www/beta.hampalyzer.com/html
cp -rf ~/hampalyzer/parsedlogs/assets/ -t /var/www/beta.hampalyzer.com/html/
cd ~/hampalyzer/dist
pm2 restart hampalyzer -- server parsedlogs /var/www/beta.hampalyzer.com/html --reparse
30 changes: 16 additions & 14 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class DB {

await this.query('TRUNCATE TABLE match');
await this.query('TRUNCATE TABLE event RESTART IDENTITY');
await this.query('TRUNCATE TABLE player RESTART IDENTITY CASCADE');
// await this.query('TRUNCATE TABLE player RESTART IDENTITY CASCADE'); // no need to truncate this

return logs;
}
Expand All @@ -75,7 +75,7 @@ export class DB {
message: "Expected one row from DB when querying for duplicates"
});

return result[0].cnt !== 0;
return result[0].cnt != 0;
}

/** Returns a unique log name */
Expand All @@ -95,7 +95,7 @@ export class DB {
});


if (hasName[0].cnt === 0)
if (hasName[0].cnt == 0)
return parse_name;

// otherwise, add some junk
Expand Down Expand Up @@ -246,17 +246,19 @@ export class DB {
private async saveTeams(client: pg.PoolClient, players: TeamComposition<OutputPlayer>, logId: number, playerMapping: Record<string, number>): Promise<void> {
for (const team in players) {
const teamPlayers = players[team] as OutputPlayer[];
for (const player of teamPlayers) {
const playerId = playerMapping[player.steamID];

client.query(
`INSERT INTO match(logid, playerid, team) VALUES ($1, $2, $3)`,
[
logId,
playerId,
+team
]
);
if (teamPlayers != null) {
for (const player of teamPlayers) {
const playerId = playerMapping[player.steamID];

client.query(
`INSERT INTO match(logid, playerid, team) VALUES ($1, $2, $3)`,
[
logId,
playerId,
+team
]
);
}
}
}
}
Expand Down

0 comments on commit 1461c11

Please sign in to comment.