1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing getting random photo with mysql #683

This commit is contained in:
Patrik J. Braun 2023-07-30 14:17:15 +02:00
parent 33ca2040a8
commit 8fc0512998
3 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,4 @@
/**
* Keeps the environment context
*/
export const ServerEnvironment = {
sendMailAvailable: false
};
export const ServerEnvironment: { sendMailAvailable?: boolean } = {};

View File

@ -382,8 +382,9 @@ export class SearchManager {
case SortingMethods.random:
if (Config.Database.type === DatabaseType.mysql) {
query.groupBy('RAND(), media.id');
} else {
query.groupBy('RANDOM()');
}
query.groupBy('RANDOM()');
break;
}
}

View File

@ -7,8 +7,6 @@ import {IConfigClass} from 'typeconfig/common';
import {PasswordHelper} from '../../../backend/model/PasswordHelper';
import {TAGS} from '../public/ClientConfig';
import {ServerEnvironment} from '../../../backend/Environment';
import {EmailMessagingType} from './MessagingConfig';
import {Logger} from '../../../backend/Logger';
declare const process: any;
@ -82,7 +80,9 @@ export class PrivateConfigClass extends ServerConfig {
require('../../../../package.json').buildCommitHash;
this.Environment.upTime = upTime;
this.Environment.isDocker = !!process.env.PI_DOCKER;
this.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable;
if (typeof ServerEnvironment.sendMailAvailable !== 'undefined') {
this.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable;
}
}
async original(): Promise<PrivateConfigClass & IConfigClass> {