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 * Keeps the environment context
*/ */
export const ServerEnvironment = { export const ServerEnvironment: { sendMailAvailable?: boolean } = {};
sendMailAvailable: false
};

View File

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

View File

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