Update trend.ts

This commit is contained in:
Acid Chicken (硫酸鶏) 2020-02-02 01:00:49 +09:00 committed by GitHub
parent 535f3ddf13
commit 9483bbb386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,9 @@ export default define(meta, async () => {
createdAt: { createdAt: {
$gt: new Date(Date.now() - rangeA) $gt: new Date(Date.now() - rangeA)
}, },
visibility: {
$in: ['public', 'home']
},
tagsLower: { tagsLower: {
$exists: true, $exists: true,
$ne: [] $ne: []
@ -79,6 +82,9 @@ export default define(meta, async () => {
const hotsPromises = limitedTags.map(async tag => { const hotsPromises = limitedTags.map(async tag => {
const passedCount = (await Note.distinct('userId', { const passedCount = (await Note.distinct('userId', {
tagsLower: tag.name, tagsLower: tag.name,
visibility: {
$in: ['public', 'home']
},
createdAt: { createdAt: {
$lt: new Date(Date.now() - rangeA), $lt: new Date(Date.now() - rangeA),
$gt: new Date(Date.now() - rangeB) $gt: new Date(Date.now() - rangeB)
@ -120,6 +126,9 @@ export default define(meta, async () => {
for (let i = 0; i < range; i++) { for (let i = 0; i < range; i++) {
countPromises.push(Promise.all(hots.map(tag => Note.distinct('userId', { countPromises.push(Promise.all(hots.map(tag => Note.distinct('userId', {
tagsLower: tag, tagsLower: tag,
visibility: {
$in: ['public', 'home']
},
createdAt: { createdAt: {
$lt: new Date(Date.now() - (interval * i)), $lt: new Date(Date.now() - (interval * i)),
$gt: new Date(Date.now() - (interval * (i + 1))) $gt: new Date(Date.now() - (interval * (i + 1)))
@ -131,6 +140,9 @@ export default define(meta, async () => {
const totalCounts: any = await Promise.all(hots.map(tag => Note.distinct('userId', { const totalCounts: any = await Promise.all(hots.map(tag => Note.distinct('userId', {
tagsLower: tag, tagsLower: tag,
visibility: {
$in: ['public', 'home']
},
createdAt: { createdAt: {
$gt: new Date(Date.now() - (interval * range)) $gt: new Date(Date.now() - (interval * range))
} }