mirror of https://github.com/laurent22/joplin.git
Server: Fixed calculation of max sizes for Postgres
parent
9c1dc7898a
commit
93a4ad09bb
|
@ -210,13 +210,13 @@ describe('UserModel', function() {
|
|||
await models().user().save({
|
||||
id: user1.id,
|
||||
account_type: AccountType.Basic,
|
||||
total_item_size: accountByType(AccountType.Basic).max_total_item_size * 0.85,
|
||||
total_item_size: Math.round(accountByType(AccountType.Basic).max_total_item_size * 0.85),
|
||||
});
|
||||
|
||||
await models().user().save({
|
||||
id: user2.id,
|
||||
account_type: AccountType.Pro,
|
||||
total_item_size: accountByType(AccountType.Pro).max_total_item_size * 0.2,
|
||||
total_item_size: Math.round(accountByType(AccountType.Pro).max_total_item_size * 0.2),
|
||||
});
|
||||
|
||||
const emailBeforeCount = (await models().email().all()).length;
|
||||
|
@ -242,7 +242,7 @@ describe('UserModel', function() {
|
|||
|
||||
await models().user().save({
|
||||
id: user2.id,
|
||||
total_item_size: accountByType(AccountType.Pro).max_total_item_size * 1.1,
|
||||
total_item_size: Math.round(accountByType(AccountType.Pro).max_total_item_size * 1.1),
|
||||
});
|
||||
|
||||
// User upload should be enabled at this point
|
||||
|
|
|
@ -383,8 +383,8 @@ export default class UserModel extends BaseModel<User> {
|
|||
.db(this.tableName)
|
||||
.select(['id', 'total_item_size', 'max_total_item_size', 'account_type', 'email', 'full_name'])
|
||||
.where(function() {
|
||||
void this.whereRaw('total_item_size > ? AND account_type = ?', [alertLimit1 * basicAccount.max_total_item_size, AccountType.Basic])
|
||||
.orWhereRaw('total_item_size > ? AND account_type = ?', [alertLimit1 * proAccount.max_total_item_size, AccountType.Pro]);
|
||||
void this.whereRaw('total_item_size > ? AND account_type = ?', [Math.round(alertLimit1 * basicAccount.max_total_item_size), AccountType.Basic])
|
||||
.orWhereRaw('total_item_size > ? AND account_type = ?', [Math.round(alertLimit1 * proAccount.max_total_item_size), AccountType.Pro]);
|
||||
})
|
||||
// Users who are disabled or who cannot upload already received the
|
||||
// notification.
|
||||
|
|
|
@ -69,14 +69,16 @@ export async function beforeAllDb(unitName: string, createDbOptions: CreateDbOpt
|
|||
const tempDir = `${packageRootDir}/temp/test-${unitName}`;
|
||||
await fs.mkdirp(tempDir);
|
||||
|
||||
// Uncomment the code below to run the test units with Postgres. Run first
|
||||
// `docker-compose -f docker-compose.db-dev.yml` to get a dev db.
|
||||
// Uncomment the code below to run the test units with Postgres. Run this:
|
||||
//
|
||||
// sudo docker compose -f docker-compose.db-dev.yml up
|
||||
|
||||
// await initConfig(Env.Dev, {
|
||||
// DB_CLIENT: 'pg',
|
||||
// POSTGRES_DATABASE: unitName,
|
||||
// POSTGRES_USER: 'joplin',
|
||||
// POSTGRES_PASSWORD: 'joplin',
|
||||
// SUPPORT_EMAIL: 'testing@localhost',
|
||||
// }, {
|
||||
// tempDir: tempDir,
|
||||
// });
|
||||
|
|
Loading…
Reference in New Issue