Skip to content

Commit

Permalink
chore: revert some changes that messed up git log
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Mar 7, 2024
1 parent 271f119 commit 2c86f28
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
45 changes: 45 additions & 0 deletions migrations/20240306175726-convert-gb-to-bytes-limits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

module.exports = {
async up(queryInterface, Sequelize) {
const convertGbToBytes = (gbValue) => gbValue * 1024 * 1024 * 1024;

const maxFileUploadSizeLimits = await queryInterface.sequelize.query(
"SELECT id, value FROM limits WHERE label = 'max-file-upload-size'",
{ type: Sequelize.QueryTypes.SELECT },
);

for (const limit of maxFileUploadSizeLimits) {
const bytesValue = convertGbToBytes(parseInt(limit.value)).toString();

await queryInterface.sequelize.query(
'UPDATE limits SET value = :bytesValue WHERE id = :id',
{
replacements: { bytesValue, id: limit.id },
type: Sequelize.QueryTypes.UPDATE,
},
);
}
},

async down(queryInterface, Sequelize) {
const convertBytesToGB = (gbValue) => gbValue / 1024 / 1024 / 1024;

const maxFileUploadSizeLimits = await queryInterface.sequelize.query(
"SELECT id, value FROM limits WHERE label = 'max-file-upload-size'",
{ type: Sequelize.QueryTypes.SELECT },
);

for (const limit of maxFileUploadSizeLimits) {
const bytesValue = convertBytesToGB(parseInt(limit.value)).toString();

await queryInterface.sequelize.query(
'UPDATE limits SET value = :bytesValue WHERE id = :id',
{
replacements: { bytesValue, id: limit.id },
type: Sequelize.QueryTypes.UPDATE,
},
);
}
},
};
15 changes: 4 additions & 11 deletions src/modules/feature-limit/feature-limit.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class FeatureLimitUsecases {
user: User,
data: LimitTypeMapping[T],
): Promise<boolean> {
if (!user.tierId) {
return false;
}

const limit = await this.limitsRepository.findLimitByLabelAndTier(
user.tierId,
limitLabel,
Expand Down Expand Up @@ -142,15 +146,4 @@ export class FeatureLimitUsecases {
async getLimitByLabelAndTier(label: string, tierId: string) {
return this.limitsRepository.findLimitByLabelAndTier(tierId, label);
}

async getTierMaxTrashStorageDays(tierId: string) {
return this.limitsRepository.findLimitByLabelAndTier(
tierId,
LimitLabels.MaxTrashStorageDays,
);
}

async getFreeTier() {
return this.limitsRepository.getFreeTier();
}
}

0 comments on commit 2c86f28

Please sign in to comment.