Skip to content

Commit

Permalink
some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Sep 20, 2023
1 parent 42bdf14 commit ef753b9
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 23 deletions.
15 changes: 10 additions & 5 deletions src/features/contribution/contribution.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ export class ContributionController {
getAvailableContributions(@Req() req: Request) {
const panelFlaskUserId = req.headers['panelFlaskUserId'];
const panelFlaskTypeId = req.headers['panelFlaskTypeId'];
if (
!isAuthenticated(panelFlaskUserId, panelFlaskTypeId) ||
panelFlaskTypeId !== FlaskUserTypesEnum.SUPER_ADMIN
) {
throw new ForbiddenException(403, 'You Are not the Super admin');
const dappFlaskUserId = req.headers['dappFlaskUserId'];
if (panelFlaskUserId) {
if (!isAuthenticated(panelFlaskUserId, panelFlaskTypeId)) {
throw new ForbiddenException(403, 'You Are not authorized');
}
}
if (dappFlaskUserId) {
if (!isAuthenticated(dappFlaskUserId, FlaskUserTypesEnum.FAMILY)) {
throw new ForbiddenException(403, 'You Are not authorized');
}
}
return this.contributionService.getAvailableContributions();
}
Expand Down
6 changes: 5 additions & 1 deletion src/features/contribution/contribution.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export class ContributionService {
) {}

getAvailableContributions(): Promise<ContributionEntity[]> {
return this.contributionRepository.find();
return this.contributionRepository.find({
order: {
createdAt: 'DESC',
},
});
}

async getContribution(contributionId: string): Promise<ContributionEntity> {
Expand Down
2 changes: 0 additions & 2 deletions src/features/midjourney/midjourney.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export class MidjourneyService {
async getReadyToSignNeeds(
options: PaginateQuery,
): Promise<Paginated<NeedEntity>> {
console.log(options);

const queryBuilder = this.needRepository
.createQueryBuilder('need')
.leftJoinAndMapOne(
Expand Down
3 changes: 0 additions & 3 deletions src/features/need/need.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,12 @@ export class NeedService {
])
.cache(60000)
.orderBy('need.created', 'ASC');
console.log('need');
return await queryBuilder.getMany();
}

async getDeleteCandidates(): Promise<[Need[], number]> {
const date = new Date();
date.setMonth(date.getMonth() - 3); // three months ago
console.log(date);

return this.flaskNeedRepository
.createQueryBuilder('need')
.leftJoinAndMapOne(
Expand Down
2 changes: 0 additions & 2 deletions src/features/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ export class SyncService {
nestReceipts.push(nestReceipt);
console.log('\x1b[36m%s\x1b[0m', 'Created a Receipt ...\n');
} else if (nestReceipt) {
console.log(receiptDetails);
await this.receiptService
.updateReceipt(receiptDetails, nestReceipt)
.then();
Expand Down Expand Up @@ -569,7 +568,6 @@ export class SyncService {
nestPayment = await this.paymentService.getPaymentById(
payments[p].id,
);
console.log(nestFamilyMember);
console.log('\x1b[36m%s\x1b[0m', 'Payment updated ...\n');
} else {
console.log('\x1b[36m%s\x1b[0m', 'Skipped Payment updating ...\n');
Expand Down
5 changes: 0 additions & 5 deletions src/features/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,6 @@ export class UserController {
purchasedCount,
deliveredCount,
);
console.log('X_LIMIT2');
console.log(X_LIMIT);
console.log(X_TAKE);
console.log(limit);
console.log(page);

return {
page,
Expand Down
1 change: 0 additions & 1 deletion src/features/wallet/wallet.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ export class WalletController {
) {

const panelFlaskUserId = Number(req.headers['panelFlaskUserId']);
console.log(panelFlaskUserId);
if (panelFlaskUserId !== Number(flaskUserId)) {
throw new WalletExceptionFilter(401, 'You only can get your signatures');
}
Expand Down
1 change: 0 additions & 1 deletion src/features/wallet/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export class WalletService {
role = getSAYRolePersian(SAYPlatformRoles.FAMILY).toString();
allRoles.push(SAYPlatformRoles.FAMILY);
}
console.log(need);

if (!role) {
throw new WalletExceptionFilter(
Expand Down
1 change: 0 additions & 1 deletion src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ export function ticketNotifications(
),
);
// when a user creates a ticket, the participants won't have a view assigned to them
// console.log(t.views);
const myView = t.views.find((v) => v.flaskUserId === flaskUserId);
const latestView = t.views.find(
(v) =>
Expand Down
3 changes: 1 addition & 2 deletions src/utils/math.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export function median(values: any[]) {
console.log(values);
if (values.length === 0) throw new Error('No inputs');
if (values.length === 0) throw new Error('No inputs');
values.sort((a, b) => {
return a - b;
});
Expand Down

0 comments on commit ef753b9

Please sign in to comment.