Fix quantity checker not factoring in entities with 0 count
All checks were successful
Test / build (push) Successful in 9s
All checks were successful
Test / build (push) Successful in 9s
This commit is contained in:
parent
a419513ea3
commit
807c87d424
2 changed files with 2 additions and 10 deletions
|
@ -47,14 +47,6 @@ export default class Inventory extends AppBaseEntity {
|
|||
return single;
|
||||
}
|
||||
|
||||
public static async ExistsByCardNumberAndUserId(userId: string, cardNumber: string): Promise<boolean> {
|
||||
const repository = AppDataSource.getRepository(Inventory);
|
||||
|
||||
const count = await repository.count({ where: { UserId: userId, CardNumber: cardNumber }});
|
||||
|
||||
return count != 0;
|
||||
}
|
||||
|
||||
public static async FetchAllByUserId(userId: string): Promise<Inventory[]> {
|
||||
const repository = AppDataSource.getRepository(Inventory);
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ export default class ImageHelper {
|
|||
const imageData = await Jimp.read(filePath);
|
||||
|
||||
if (userId != null) {
|
||||
const claimed = await Inventory.ExistsByCardNumberAndUserId(userId, card.id);
|
||||
const claimed = await Inventory.FetchOneByCardNumberAndUserId(userId, card.id);
|
||||
|
||||
if (!claimed) {
|
||||
if (!claimed || claimed.Quantity == 0) {
|
||||
imageData.greyscale();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue