Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Nicolai Ort | 9581185b24 | |
Nicolai Ort | 2905884c02 | |
Nicolai Ort | e9914e317b | |
Nicolai Ort | 702070da66 |
|
@ -2,9 +2,18 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
||||
|
||||
#### [v0.15.1](https://git.odit.services/lfk/backend/compare/v0.15.0...v0.15.1)
|
||||
|
||||
- Faster trackscan creation by only loading the latest scan [`e9914e3`](https://git.odit.services/lfk/backend/commit/e9914e317b7fd78863cfd8549bad65da9292b7ca)
|
||||
- Log batch time in mass scan script [`2905884`](https://git.odit.services/lfk/backend/commit/2905884c024d7f275b3ad2c2858a2f0911adb95b)
|
||||
- Dont load cards with get all runners request [`702070d`](https://git.odit.services/lfk/backend/commit/702070da669cc605b93e6f5b62d712c28f079dd0)
|
||||
|
||||
#### [v0.15.0](https://git.odit.services/lfk/backend/compare/v0.14.6...v0.15.0)
|
||||
|
||||
> 15 April 2023
|
||||
|
||||
- Added test script for creating mass scans [`8007117`](https://git.odit.services/lfk/backend/commit/80071174342d87199fcbd981cd8c92300b0a51e4)
|
||||
- 🚀Bumped version to v0.15.0 [`cc89ba8`](https://git.odit.services/lfk/backend/commit/cc89ba8afb3120569613a889baf962555612e95a)
|
||||
- Get all scans speed improvement [`23fa78e`](https://git.odit.services/lfk/backend/commit/23fa78eb9dcc01ecc036347f6703aacc0d163d7d)
|
||||
- More scan request optimizations [`7c4ff42`](https://git.odit.services/lfk/backend/commit/7c4ff42a3b3e7b186e16c85a97d9ecc854a32cb0)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@odit/lfk-backend",
|
||||
"version": "0.15.0",
|
||||
"version": "0.15.1",
|
||||
"main": "src/app.ts",
|
||||
"repository": "https://git.odit.services/lfk/backend",
|
||||
"engines": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { Repository, getConnectionManager } from 'typeorm';
|
||||
import { RunnerGroupNeededError, RunnerHasDistanceDonationsError, RunnerIdsNotMatchingError, RunnerNotFoundError } from '../errors/RunnerErrors';
|
||||
import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors';
|
||||
import { CreateRunner } from '../models/actions/create/CreateRunner';
|
||||
|
@ -32,7 +32,7 @@ export class RunnerController {
|
|||
@OpenAPI({ description: 'Lists all runners from all teams/orgs. <br> This includes the runner\'s group and distance ran.' })
|
||||
async getAll() {
|
||||
let responseRunners: ResponseRunner[] = new Array<ResponseRunner>();
|
||||
const runners = await this.runnerRepository.find({ relations: ['scans', 'group', 'group.parentGroup', 'scans.track', 'cards'] });
|
||||
const runners = await this.runnerRepository.find({ relations: ['scans', 'group', 'group.parentGroup', 'scans.track'] });
|
||||
runners.forEach(runner => {
|
||||
responseRunners.push(new ResponseRunner(runner));
|
||||
});
|
||||
|
|
|
@ -86,14 +86,13 @@ export class CreateTrackScan {
|
|||
* @returns The validated scan with it's laptime set.
|
||||
*/
|
||||
public async validateScan(scan: TrackScan): Promise<TrackScan> {
|
||||
const scans = await getConnection().getRepository(TrackScan).find({ where: { runner: scan.runner, valid: true }, relations: ["track"] });
|
||||
if (scans.length == 0) {
|
||||
const latestScan = await getConnection().getRepository(TrackScan).findOne({ where: { runner: scan.runner, valid: true }, relations: ["track"], order: { id: 'DESC' } });
|
||||
if (!latestScan) {
|
||||
scan.lapTime = 0;
|
||||
scan.valid = true;
|
||||
}
|
||||
else {
|
||||
const newestScan = scans[scans.length - 1];
|
||||
scan.lapTime = scan.timestamp - newestScan.timestamp;
|
||||
scan.lapTime = scan.timestamp - latestScan.timestamp;
|
||||
scan.valid = (scan.lapTime > scan.track.minimumLapTime);
|
||||
}
|
||||
return scan;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import axios from 'axios';
|
||||
|
||||
async function main() {
|
||||
console.time("batches")
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const batch = [];
|
||||
for (let i = 0; i < 20; i++) {
|
||||
for (let i = 0; i < 6; i++) {
|
||||
batch.push(axios.post('http://localhost:4010/api/scans/trackscans', { card: 200000000001, station: 2 }, {
|
||||
headers: {
|
||||
Authorization: 'Bearer 10F2E64.BB4F6CC5-2148-4CCF-88B5-0AA85D0508A9'
|
||||
|
@ -11,7 +12,8 @@ async function main() {
|
|||
}))
|
||||
}
|
||||
await Promise.all(batch)
|
||||
console.log(`Finished batch ${i}`)
|
||||
console.timeLog("batches", `Finished batch ${i}`)
|
||||
}
|
||||
console.timeEnd("batches")
|
||||
}
|
||||
main();
|
Loading…
Reference in New Issue