update past week number in post

This commit is contained in:
MuslemRahimi 2024-06-03 21:57:43 +02:00
parent 0c81aba202
commit 92e8337970

View File

@ -36,12 +36,12 @@ module.exports = function (fastify, opts, done) {
if(data?.sortingPosts === 'hot') { if(data?.sortingPosts === 'hot') {
//community page code space //community page code space
// In case of sort === 'hot' show the most recent post up to 4 week by ranking them with the function postHotness // In case of sort === 'hot' show the most recent post up to 7 week by ranking them with the function postHotness
let endDate = new Date(); let endDate = new Date();
// Get the date one week earlier // Get the date one week earlier
let startDate = new Date(); let startDate = new Date();
startDate.setDate(endDate.getDate() - 30); startDate.setDate(endDate.getDate() - 7);
// Format the dates as needed (e.g., "YYYY-MM-DD") // Format the dates as needed (e.g., "YYYY-MM-DD")
let endDateStr = endDate.toISOString().split('T')[0]; let endDateStr = endDate.toISOString().split('T')[0];
@ -94,14 +94,14 @@ module.exports = function (fastify, opts, done) {
else { else {
//community page code space //community page code space
// In case of sort === 'hot' show the most recent post up to 4 week by ranking them with the function postHotness // In case of sort === 'hot' show the most recent post up to 7 week by ranking them with the function postHotness
if(data?.sortingPosts === 'hot') { if(data?.sortingPosts === 'hot') {
let endDate = new Date(); let endDate = new Date();
// Get the date one week earlier // Get the date one week earlier
let startDate = new Date(); let startDate = new Date();
startDate.setDate(endDate.getDate() - 30); startDate.setDate(endDate.getDate() - 7);
// Format the dates as needed (e.g., "YYYY-MM-DD") // Format the dates as needed (e.g., "YYYY-MM-DD")
let endDateStr = endDate.toISOString().split('T')[0]; let endDateStr = endDate.toISOString().split('T')[0];