script agenda du libre osm 7 jours
This commit is contained in:
parent
cc99a802e0
commit
eddf735722
@ -9,9 +9,14 @@ function makeTitleContentFromAgendaDulibre(articles) {
|
||||
|
||||
let content = '';
|
||||
|
||||
if(! articles.length ){
|
||||
return '- Aucun évènement prévu. T_T'
|
||||
}
|
||||
articles.forEach(item=>{
|
||||
content += `\n* ${item.city} - ${item.title}` ;
|
||||
content += `\n* <${item.start_time} -- ${item.end_time}>` ;
|
||||
let start = new Date(item.start_time)
|
||||
let end = new Date(item.end_time)
|
||||
content += `\n <${start} -- ${end}>` ;
|
||||
})
|
||||
return content;
|
||||
}
|
||||
@ -19,11 +24,12 @@ function makeTitleContentFromAgendaDulibre(articles) {
|
||||
async function postLink() {
|
||||
|
||||
console.log("curator: résumé des prochains évènements de l'agenda du libre en ile de france dans les " + days_filter + " jours")
|
||||
let events_list = coming_events_json.default;
|
||||
|
||||
coming_events_json = getArticlesFromDaysInJson(coming_events_json);
|
||||
events_list = getArticlesFromDaysInJson(events_list,days_filter);
|
||||
|
||||
let contentOfPost = 'Prochains évènements OpenStreetMap dans les ' + days_filter + ' prochains jours: \n'
|
||||
+ makeTitleContentFromAgendaDulibre(coming_events_json)
|
||||
+ makeTitleContentFromAgendaDulibre(events_list)
|
||||
|
||||
let configPost = {
|
||||
author: 'curator',
|
||||
@ -32,7 +38,7 @@ async function postLink() {
|
||||
slug: "osm_event_picture",
|
||||
content_type: "text/markdown",
|
||||
folder_image: process.cwd() + '/assets/',
|
||||
image: "osm.jpg",
|
||||
image: "osm_default.jpg",
|
||||
message: `# ${contentOfPost}
|
||||
|
||||
#agenda #floss #openstreetmap #hebdo`,
|
||||
|
@ -419,12 +419,16 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
||||
let today = new Date()
|
||||
let selectedEvents = [];
|
||||
|
||||
console.log('getArticlesFromDaysInJson: filtre nbOfDays', nbOfDays)
|
||||
json_content.forEach((item) => {
|
||||
|
||||
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
||||
|
||||
if(differenceDays>0 && differenceDays < nbOfDays){
|
||||
if( differenceDays <= nbOfDays){
|
||||
console.log('on garde', item.title)
|
||||
selectedEvents.push(item)
|
||||
}else{
|
||||
// console.log('on ne garde pas')
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user