Massive/best.service.ts
Brandon Presley 85915b9aa0 Retrieve last set when running a plan - 1.145
Closes brandon.presley/Massive#162

We should just keep it simple and get the most recent set instead of
trying to figure out what the best kind of maximum would be.
2023-07-23 13:59:11 +12:00

16 lines
390 B
TypeScript

import { setRepo } from './db'
import GymSet from './gym-set'
export const getBestSet = async (name: string): Promise<GymSet> => {
return setRepo
.createQueryBuilder()
.select()
.addSelect('MAX(weight)', 'weight')
.where('name = :name', { name })
.groupBy('name')
.addGroupBy('reps')
.orderBy('weight', 'DESC')
.addOrderBy('reps', 'DESC')
.getOne()
}