Ciao a tutti,
Sto lavorando per ottenere i primi 3 argomenti con le risposte più attive negli ultimi 30 giorni, voglio mostrare solo quegli argomenti e sto personalizzando il plugin showcase category, quindi lato js ho eseguito il codice sottostante ma sembra che restituisca una promise. Qualcuno può dirmi come posso fare?
showcased-topic-list.js
this.store.findFiltered("topicList", filter).then((topicList) => {
var idaas = [];
var final_arr = [];
topicList.topics = topicList.topics.forEach(async (t) => {
const response = await ajax(`/t/${t.id}/posts.json`).then(async (result) => {
await result.post_stream.posts.forEach((p) => {
let date1 = new Date();
let date2 = new Date(p.created_at);
let Difference_In_Time = date1.getTime() - date2.getTime();
let Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
if (Difference_In_Days <= 30) {
idaas.push(result.id);
}
});
return idaas;
});
final_arr.push(response);
});
});
example:
var smallarrq = ['71782', '72307'];
this.set(
"topicList",
topicList.topics.filter((t) => smallarrq.includes(t.id)).slice(0, settings.max_list_length)
);
Voglio che questo array final_arr assomigli all’array smallarrq sopra, ma restituisce come promise.
Per favore aiutatemi, ci sto lavorando da molti giorni.
Grazie,