Update trend.ts
This commit is contained in:
parent
535f3ddf13
commit
9483bbb386
1 changed files with 12 additions and 0 deletions
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue