Skip to content

Commit 3c652e8

Browse files
committed
revert db query
1 parent 37149eb commit 3c652e8

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

server/crons/rssFeed.cron.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,20 @@ function encode(text) {
8080
}
8181

8282
async function callback() {
83-
const posts = await Post
84-
.find({
85-
status: 'publish',
86-
mp3: { $exists: true },
87-
})
88-
.sort({ date: -1 })
89-
.lean();
83+
// const posts = await Post
84+
// .find({
85+
// status: 'publish',
86+
// mp3: { $exists: true },
87+
// })
88+
// .sort({ date: -1 })
89+
// .lean();
90+
91+
const posts = await Post.find().where('status').equals('publish').lean();
92+
93+
// mongoose sort is slower
94+
posts.sort((o1, o2) => {
95+
return o1.date >= o2.date ? -1 : 1;
96+
});
9097

9198
const publicFeedAllConfig = cloneDeep(rawFeedConfig);
9299
const publicFeedConfig = cloneDeep(rawFeedConfig);
@@ -101,6 +108,8 @@ async function callback() {
101108
posts.forEach((post) => {
102109
episode -= 1;
103110

111+
if (!post.mp3) return; // missing mp3 breaks the rss list
112+
104113
let description;
105114

106115
const extractedDescription = post.excerpt.rendered.match(/ Download (.*?)[<]/) || post.excerpt.rendered.match(/[>](.*?)[<]/);

0 commit comments

Comments
 (0)