import { Injectable } from '@nestjs/common';
import { OnlineSnapshot as PrismaOnlineSnapshot } from '@prisma/client';
import { OnlineSnapshot } from '../../../domain/entities/online-snapshot.entity';

@Injectable()
export class OnlineSnapshotMapper {
  toDomain(prisma: PrismaOnlineSnapshot): OnlineSnapshot {
    return OnlineSnapshot.reconstitute({
      id: prisma.id,
      ts: prisma.ts,
      onlineCount: prisma.onlineCount,
      windowSeconds: prisma.windowSeconds,
    });
  }

  toPersistence(domain: OnlineSnapshot): Omit<PrismaOnlineSnapshot, 'id'> {
    return {
      ts: domain.ts,
      onlineCount: domain.onlineCount,
      windowSeconds: domain.windowSeconds,
    };
  }
}
