@@ -20,7 +20,7 @@ import { GameTheme } from "./entities/game-theme.entity";
2020import { GamePlayerPerspective } from "./entities/game-player-perspective.entity" ;
2121import { GameEngine } from "./entities/game-engine.entity" ;
2222import { GameEngineLogo } from "./entities/game-engine-logo.entity" ;
23- import { PartialGame } from "./game-repository.types" ;
23+ import { IDGBPartialGame } from "./game-repository.types" ;
2424import { StatisticsQueueService } from "../../statistics/statistics-queue/statistics-queue.service" ;
2525import { StatisticsSourceType } from "../../statistics/statistics.constants" ;
2626import { ExternalGameService } from "../external-game/external-game.service" ;
@@ -100,7 +100,7 @@ export class GameRepositoryCreateService {
100100 private readonly externalGameService : ExternalGameService ,
101101 ) { }
102102
103- async shouldUpdate ( game : PartialGame ) {
103+ async shouldUpdate ( game : IDGBPartialGame ) {
104104 if ( game . id == null || typeof game . id !== "number" ) {
105105 return false ;
106106 } else if (
@@ -121,7 +121,7 @@ export class GameRepositoryCreateService {
121121 * Bug info: https://github.com/typeorm/typeorm/issues/1754
122122 * @param game
123123 */
124- async createOrUpdate ( game : PartialGame ) {
124+ async createOrUpdate ( game : IDGBPartialGame ) {
125125 const shouldProcess = await this . shouldUpdate ( game ) ;
126126
127127 if ( ! shouldProcess ) {
@@ -141,7 +141,7 @@ export class GameRepositoryCreateService {
141141 }
142142
143143 private dispatchCreateUpdateEvent (
144- game : PartialGame ,
144+ game : IDGBPartialGame ,
145145 isUpdateAction : boolean ,
146146 ) {
147147 if ( ! isUpdateAction ) {
@@ -158,7 +158,7 @@ export class GameRepositoryCreateService {
158158 * e.g. Relationships where Game is on the ManyToOne side. Do not update ManyToMany models here.
159159 * @param game
160160 */
161- async buildParentRelationships ( game : PartialGame ) {
161+ async buildParentRelationships ( game : IDGBPartialGame ) {
162162 if ( game . collection ) {
163163 // collection.games changes are not cascaded.
164164 const collection = this . gameCollectionRepository . create (
@@ -175,7 +175,7 @@ export class GameRepositoryCreateService {
175175 * <strong> We assume the game is already persisted at this point, so we can use it as a parent.</strong>
176176 * @param game
177177 */
178- async buildChildRelationships ( game : PartialGame ) {
178+ async buildChildRelationships ( game : IDGBPartialGame ) {
179179 if ( game . alternativeNames ) {
180180 const alternativeNames = game . alternativeNames . map (
181181 ( alternativeName ) => {
@@ -231,10 +231,17 @@ export class GameRepositoryCreateService {
231231 */
232232 if ( game . externalGames ) {
233233 for ( const externalGame of game . externalGames ) {
234+ const category =
235+ externalGame . category ?? externalGame . externalGameSource ;
236+ const media =
237+ externalGame . media ?? externalGame . gameReleaseFormat ;
238+
234239 try {
235240 await this . externalGameService . upsert ( {
236241 ...externalGame ,
237242 gameId : game . id ,
243+ category,
244+ media,
238245 } ) ;
239246 } catch ( e ) { }
240247 }
0 commit comments