parent
61461b7f59
commit
68571d8f57
10 changed files with 92 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { USER_ONLINE_THRESHOLD } from '@/const';
|
||||
import { Users } from '@/models';
|
||||
import { MoreThan } from 'typeorm';
|
||||
import define from '../define';
|
||||
import { redisClient } from '../../../db/redis';
|
||||
import config from '@/config';
|
||||
|
||||
export const meta = {
|
||||
tags: ['meta'],
|
||||
|
|
@ -11,12 +12,12 @@ export const meta = {
|
|||
}
|
||||
};
|
||||
|
||||
export default define(meta, (ps, user) => {
|
||||
return new Promise((res, rej) => {
|
||||
redisClient.pubsub('numsub', config.host, (_, x) => {
|
||||
res({
|
||||
count: x[1]
|
||||
});
|
||||
});
|
||||
export default define(meta, async () => {
|
||||
const count = await Users.count({
|
||||
lastActiveDate: MoreThan(new Date(Date.now() - USER_ONLINE_THRESHOLD))
|
||||
});
|
||||
|
||||
return {
|
||||
count
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue