Skip to content

Commit

Permalink
0.10.15
Browse files Browse the repository at this point in the history
  • Loading branch information
LaFr4nc3 committed Oct 31, 2019
1 parent 91c657f commit 278bcb9
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions backend/src/matching.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line no-unused-vars
import { Repository } from 'typeorm'
import { Repository, Between } from 'typeorm'
import * as _ from 'lodash'
// eslint-disable-next-line no-unused-vars
import moment from 'moment'
import User, { Gender } from './entity/User'

function euclideanDistance(xs: number[], ys: number[]): number {
Expand Down Expand Up @@ -154,7 +153,18 @@ async function matching(userRepository: Repository<User>): Promise<User[]> {
await userRepository.save(users)

const M2MUsers = await userRepository.find({
where: { gender: Gender.MALE, partnerGender: Gender.MALE }
where: {
gender: Gender.MALE,
partnerGender: Gender.MALE,
createdAt: Between(
moment()
.startOf('day')
.toDate(),
moment()
.endOf('day')
.toDate()
)
}
})
const M2MUsers2 = M2MUsers.splice(Math.floor(M2MUsers.length / 2))

Expand All @@ -172,7 +182,18 @@ async function matching(userRepository: Repository<User>): Promise<User[]> {
console.groupEnd()

const F2FUsers = await userRepository.find({
where: { gender: Gender.FEMALE, partnerGender: Gender.FEMALE }
where: {
gender: Gender.FEMALE,
partnerGender: Gender.FEMALE,
createdAt: Between(
moment()
.startOf('day')
.toDate(),
moment()
.endOf('day')
.toDate()
)
}
})
const F2FUsers2 = F2FUsers.splice(Math.floor(F2FUsers.length / 2))

Expand All @@ -190,10 +211,32 @@ async function matching(userRepository: Repository<User>): Promise<User[]> {
console.groupEnd()

const M2FUsers = await userRepository.find({
where: { gender: Gender.MALE, partnerGender: Gender.FEMALE }
where: {
gender: Gender.MALE,
partnerGender: Gender.FEMALE,
createdAt: Between(
moment()
.startOf('day')
.toDate(),
moment()
.endOf('day')
.toDate()
)
}
})
const F2MUsers = await userRepository.find({
where: { gender: Gender.FEMALE, partnerGender: Gender.MALE }
where: {
gender: Gender.FEMALE,
partnerGender: Gender.MALE,
createdAt: Between(
moment()
.startOf('day')
.toDate(),
moment()
.endOf('day')
.toDate()
)
}
})

const M2FUsersRanks = generateUsersRanks(M2FUsers, F2MUsers)
Expand Down

0 comments on commit 278bcb9

Please # to comment.