-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe37dcd
commit 389a8d2
Showing
61 changed files
with
1,278 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { addSeconds } from 'date-fns'; | ||
import SessionRepository from '../repositories/SessionRepository.js'; | ||
import { transaction } from './transaction.js'; | ||
|
||
export async function startTimer(sessionId: string): Promise<number> { | ||
return await transaction(async (manager) => { | ||
const sessionRepository = manager.withRepository(SessionRepository); | ||
const session = await sessionRepository.findOneBy({ id: sessionId }); | ||
if (!session) { | ||
throw new Error('Session not found'); | ||
} | ||
const duration = session.options.timerDuration; | ||
session.timer = addSeconds(new Date(), duration); | ||
await sessionRepository.save(session); | ||
|
||
return duration; | ||
}); | ||
} | ||
|
||
export async function stopTimer(sessionId: string): Promise<void> { | ||
return await transaction(async (manager) => { | ||
const sessionRepository = manager.withRepository(SessionRepository); | ||
const session = await sessionRepository.findOneBy({ id: sessionId }); | ||
if (!session) { | ||
throw new Error('Session not found'); | ||
} | ||
session.timer = null; | ||
await sessionRepository.save(session); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class TimerOnSession1674905273870 implements MigrationInterface { | ||
name = 'TimerOnSession1674905273870' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" ADD "timer" TIMESTAMP WITH TIME ZONE`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "timer"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class TimerOptions1674905786619 implements MigrationInterface { | ||
name = 'TimerOptions1674905786619' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "templates" ADD "options_allow_timer" boolean NOT NULL DEFAULT false`); | ||
await queryRunner.query(`ALTER TABLE "templates" ADD "options_timer_duration" numeric NOT NULL DEFAULT '900'`); | ||
await queryRunner.query(`ALTER TABLE "sessions" ADD "options_allow_timer" boolean NOT NULL DEFAULT false`); | ||
await queryRunner.query(`ALTER TABLE "sessions" ADD "options_timer_duration" numeric NOT NULL DEFAULT '900'`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "options_timer_duration"`); | ||
await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "options_allow_timer"`); | ||
await queryRunner.query(`ALTER TABLE "templates" DROP COLUMN "options_timer_duration"`); | ||
await queryRunner.query(`ALTER TABLE "templates" DROP COLUMN "options_allow_timer"`); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/db/migrations/1675096520361-LockControlsTimerEnd.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class LockControlsTimerEnd1675096520361 implements MigrationInterface { | ||
name = 'LockControlsTimerEnd1675096520361' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "templates" ADD "options_readonly_on_timer_end" boolean NOT NULL DEFAULT true`); | ||
await queryRunner.query(`ALTER TABLE "sessions" ADD "options_readonly_on_timer_end" boolean NOT NULL DEFAULT true`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "options_readonly_on_timer_end"`); | ||
await queryRunner.query(`ALTER TABLE "templates" DROP COLUMN "options_readonly_on_timer_end"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
All fonts designed and copyrighted Jakob Fischer / pizzadude.dk | ||
|
||
The fonts are provided free for personal or commercial use, however they may not be redistributed, sold or modified without the permission of Jakob Fischer / pizzadude.dk. | ||
|
||
I have decided to let people use my freeware fonts without paying the usual $US25 commercial fee - but, I urge people to buy one of my commercial fonts as compensation and/or creating a link to www.pizzadude.dk | ||
|
||
Jakob Fischer / pizzadude.dk is not liable for any damage resulting from the use of these fonts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.