Skip to content

Commit

Permalink
Add kwipment and IFullPayloadAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Moschkin committed Sep 15, 2024
1 parent 50cc497 commit 07d3808
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/abstract/voyagetracker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ITrackedAssignment, ITrackedVoyage } from "../datacore/voyage";
import { IFullPayloadAssignment, ITrackedAssignment, ITrackedVoyage } from "../datacore/voyage";
import { TrackedCrew, TrackedVoyage } from "../models/Tracked";

import { Logger, LogData } from "../logic/logger";
Expand Down Expand Up @@ -148,7 +148,7 @@ export abstract class VoyageTrackerBase {
async postTrackedData(
dbid: number,
voyage: ITrackedVoyage,
assignments: ITrackedAssignment[],
assignments: IFullPayloadAssignment[],
logData: LogData
): Promise<ApiResult> {
Logger.info("Tracked Voyage data", { dbid, voyage, logData });
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/api.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router, Request, Response } from 'express';
import { ApiResult, DataCoreAPI, LogData } from '../logic';
import { PlayerData } from '../datacore/player';
import { ITrackedAssignment, ITrackedVoyage } from '../datacore/voyage';
import { IFullPayloadAssignment, ITrackedAssignment, ITrackedPayload, ITrackedVoyage } from '../datacore/voyage';
import { IFBB_BossBattle_Document } from '../models/BossBattles';
import { CrewTrial, Solve } from '../datacore/boss';
import { VoyageTrackerAPI } from '../logic/voyagetracker';
Expand Down Expand Up @@ -302,9 +302,8 @@ router.post('/postTrackedData', async (req: Request, res: Response, next) => {
return;
}
try {
let dbid = req.body.dbid;
let voyage = req.body.voyage as ITrackedVoyage;
let assignments = req.body.assignments as ITrackedAssignment[];
let payload = req.body as ITrackedPayload;
const { dbid, voyage, assignments } = payload;
let apiResult = await VoyageTrackerAPI.postTrackedData(dbid, voyage, assignments, getLogDataFromReq(req));
res.status(apiResult.Status).send(apiResult.Body);
} catch (e) {
Expand Down
13 changes: 11 additions & 2 deletions app/datacore/voyage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,23 @@ export interface ITrackedAssignmentsByCrew {
[key: string]: ITrackedAssignment[]; // key is crew.symbol
};


export interface ITrackedAssignment {
tracker_id: number;
slot: number; // Slot index where crew is seated
trait: string; // Matched trait or empty string if no match
crew?: string;
};

export interface IFullPayloadAssignment extends ITrackedAssignment {
crew: string;
kwipment?: number[] | number[][];
}

export interface ITrackedPayload {
dbid: number;
voyage: ITrackedVoyage;
assignments: IFullPayloadAssignment[];
}

export interface ITrackedAssignmentsBySkill {
[key: string]: {
ids: number[],
Expand Down
4 changes: 2 additions & 2 deletions app/logic/voyagetracker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ITrackedAssignment, ITrackedVoyage } from "../datacore/voyage";
import { IFullPayloadAssignment, ITrackedAssignment, ITrackedVoyage } from "../datacore/voyage";
import { TrackedCrew, TrackedVoyage } from "../models/Tracked";
import { makeSql } from "../sequelize";
import { TrackerPostResult, VoyageTrackerBase } from "../abstract/voyagetracker";
Expand Down Expand Up @@ -126,7 +126,7 @@ export class VoyageTracker extends VoyageTrackerBase {
protected async postOrPutTrackedData(
dbid: number,
voyage: ITrackedVoyage,
assignments: ITrackedAssignment[],
assignments: IFullPayloadAssignment[],
timeStamp: Date = new Date()
): Promise<TrackerPostResult> {
const sql = await makeSql(dbid);
Expand Down
4 changes: 2 additions & 2 deletions app/models/Tracked.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Column, CreatedAt, DataType, Model, Table, UpdatedAt } from "sequelize-typescript";
import { ITrackedVoyage, ITrackedAssignment } from "../datacore/voyage";
import { ITrackedVoyage, ITrackedAssignment, IFullPayloadAssignment } from "../datacore/voyage";

export interface ITelemetryVoyage {
crewSymbol: string;
Expand Down Expand Up @@ -62,7 +62,7 @@ export class TrackedCrew extends Model implements ITrackedCrewRecord {
trackerId!: number;

@Column(DataType.JSON)
assignment!: ITrackedAssignment;
assignment!: ITrackedAssignment | IFullPayloadAssignment;

@CreatedAt
timeStamp!: Date;
Expand Down

0 comments on commit 07d3808

Please sign in to comment.