Rename mentor matching to similar players
This commit is contained in:
1 parent
cfbc74d882
commit
ce00bc84b5
14 files changed
+529
-388
No files matched your search
@@ -3,8 +3,8 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import {
|
||||
FEATURE_SCHEMA_VERSION,
|
||||
type MentorMatchesDto,
|
||||
type PlayerAnalysisDto,
|
||||
type SimilarPlayersDto,
|
||||
} from '@persona-lenz/shared';
|
||||
import request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
ANALYSIS_QUEUE_NAME,
|
||||
SEED_COLLECTION_QUEUE_NAME,
|
||||
} from './../src/modules/analysis/analysis.constants';
|
||||
import { MentorMatchService } from './../src/modules/analysis/mentor-match.service';
|
||||
import { SimilarPlayerService } from './../src/modules/analysis/similar-player.service';
|
||||
import { ConnectionService } from './../src/modules/global/database/connection.service';
|
||||
import { REDIS_CLIENT } from './../src/modules/global/redis/redis.constants';
|
||||
import { SecretService } from './../src/modules/global/secret/secret.service';
|
||||
@@ -25,8 +25,8 @@ describe('AppController (e2e)', () => {
|
||||
let analysisQueueService: {
|
||||
enqueueUserAnalysis: jest.Mock;
|
||||
};
|
||||
let mentorMatchService: {
|
||||
findMentorMatches: jest.Mock;
|
||||
let similarPlayerService: {
|
||||
findSimilarPlayers: jest.Mock;
|
||||
};
|
||||
let connectionService: {
|
||||
getModel: jest.Mock;
|
||||
@@ -44,8 +44,8 @@ describe('AppController (e2e)', () => {
|
||||
analysisQueueService = {
|
||||
enqueueUserAnalysis: jest.fn(),
|
||||
};
|
||||
mentorMatchService = {
|
||||
findMentorMatches: jest.fn(),
|
||||
similarPlayerService = {
|
||||
findSimilarPlayers: jest.fn(),
|
||||
};
|
||||
connectionService = {
|
||||
getModel: jest.fn(),
|
||||
@@ -57,8 +57,8 @@ describe('AppController (e2e)', () => {
|
||||
.useValue(connectionService)
|
||||
.overrideProvider(AnalysisQueueService)
|
||||
.useValue(analysisQueueService)
|
||||
.overrideProvider(MentorMatchService)
|
||||
.useValue(mentorMatchService)
|
||||
.overrideProvider(SimilarPlayerService)
|
||||
.useValue(similarPlayerService)
|
||||
.overrideProvider(SecretService)
|
||||
.useValue({
|
||||
get: jest.fn((key: string) => {
|
||||
@@ -446,18 +446,19 @@ describe('AppController (e2e)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('/api/players/:puuid/mentor-matches (GET) returns mentor matches with display Riot IDs', async () => {
|
||||
mentorMatchService.findMentorMatches.mockResolvedValue({
|
||||
it('/api/players/:puuid/similar-players (GET) returns similar players with display Riot IDs', async () => {
|
||||
similarPlayerService.findSimilarPlayers.mockResolvedValue({
|
||||
puuid: 'target-puuid',
|
||||
queueId: 420,
|
||||
profileUpdatedAt: new Date('2026-07-02T00:00:00.000Z'),
|
||||
matches: [
|
||||
{
|
||||
puuid: 'mentor-puuid',
|
||||
puuid: 'similar-player-puuid',
|
||||
similarityScore: 0.87,
|
||||
finalScore: 0.81,
|
||||
tier: 'CHALLENGER',
|
||||
leaguePoints: 900,
|
||||
tierComparison: 'higher',
|
||||
mainRole: 'MIDDLE',
|
||||
mainChampions: [{ championId: 103, games: 20, wins: 14 }],
|
||||
sampleGameCount: 40,
|
||||
@@ -465,16 +466,24 @@ describe('AppController (e2e)', () => {
|
||||
{
|
||||
metricId: 'kda',
|
||||
currentValue: 0.3,
|
||||
mentorValue: 0.31,
|
||||
otherValue: 0.31,
|
||||
absoluteGap: 0.01,
|
||||
},
|
||||
],
|
||||
gapMetrics: [
|
||||
strongerMetrics: [
|
||||
{
|
||||
metricId: 'goldPerMin',
|
||||
currentValue: 0.5,
|
||||
mentorValue: 0.8,
|
||||
mentorAdvantage: 0.3,
|
||||
otherValue: 0.8,
|
||||
lead: 0.3,
|
||||
},
|
||||
],
|
||||
weakerMetrics: [
|
||||
{
|
||||
metricId: 'visionScorePerMin',
|
||||
currentValue: 0.6,
|
||||
otherValue: 0.4,
|
||||
lead: 0.2,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -483,7 +492,7 @@ describe('AppController (e2e)', () => {
|
||||
const accountFind = jest.fn(() =>
|
||||
createLeanExec([
|
||||
{
|
||||
puuid: 'mentor-puuid',
|
||||
puuid: 'similar-player-puuid',
|
||||
gameName: '프리리',
|
||||
tagLine: 'KR1',
|
||||
},
|
||||
@@ -494,17 +503,17 @@ describe('AppController (e2e)', () => {
|
||||
});
|
||||
|
||||
const response = await request(app.getHttpServer())
|
||||
.get('/api/players/target-puuid/mentor-matches?limit=3')
|
||||
.get('/api/players/target-puuid/similar-players?limit=3')
|
||||
.expect(200);
|
||||
const responseBody = response.body as MentorMatchesDto;
|
||||
const responseBody = response.body as SimilarPlayersDto;
|
||||
|
||||
expect(mentorMatchService.findMentorMatches).toHaveBeenCalledWith(
|
||||
expect(similarPlayerService.findSimilarPlayers).toHaveBeenCalledWith(
|
||||
'target-puuid',
|
||||
420,
|
||||
3,
|
||||
);
|
||||
expect(accountFind).toHaveBeenCalledWith({
|
||||
puuid: { $in: ['mentor-puuid'] },
|
||||
puuid: { $in: ['similar-player-puuid'] },
|
||||
});
|
||||
expect(responseBody).toEqual({
|
||||
puuid: 'target-puuid',
|
||||
@@ -512,7 +521,7 @@ describe('AppController (e2e)', () => {
|
||||
profileUpdatedAt: '2026-07-02T00:00:00.000Z',
|
||||
matches: [
|
||||
{
|
||||
mentorDisplayId: 'mentor-1',
|
||||
displayId: 'similar-1',
|
||||
riotId: {
|
||||
gameName: '프리리',
|
||||
tagLine: 'KR1',
|
||||
@@ -521,6 +530,7 @@ describe('AppController (e2e)', () => {
|
||||
finalScore: 0.81,
|
||||
tier: 'CHALLENGER',
|
||||
leaguePoints: 900,
|
||||
tierComparison: 'higher',
|
||||
mainRole: 'MIDDLE',
|
||||
mainChampions: [{ championId: 103, games: 20, wins: 14 }],
|
||||
sampleGameCount: 40,
|
||||
@@ -528,16 +538,24 @@ describe('AppController (e2e)', () => {
|
||||
{
|
||||
metricId: 'kda',
|
||||
currentValue: 0.3,
|
||||
mentorValue: 0.31,
|
||||
otherValue: 0.31,
|
||||
absoluteGap: 0.01,
|
||||
},
|
||||
],
|
||||
gapMetrics: [
|
||||
strongerMetrics: [
|
||||
{
|
||||
metricId: 'goldPerMin',
|
||||
currentValue: 0.5,
|
||||
mentorValue: 0.8,
|
||||
mentorAdvantage: 0.3,
|
||||
otherValue: 0.8,
|
||||
lead: 0.3,
|
||||
},
|
||||
],
|
||||
weakerMetrics: [
|
||||
{
|
||||
metricId: 'visionScorePerMin',
|
||||
currentValue: 0.6,
|
||||
otherValue: 0.4,
|
||||
lead: 0.2,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user