add place info in description
This commit is contained in:
parent
d09767dd4e
commit
71fecd1961
@ -17,15 +17,15 @@ const parserConfig = {
|
||||
askOsmCal: false,
|
||||
runAddQueriesToMobilizonBDD: false,
|
||||
debug: false,
|
||||
organizerActorId: 3, // ID of the user who imports events in the mobilizon instance. 3 is the first admin user created, usually.
|
||||
organizerActorId: 4, // ID of the user who imports events in the mobilizon instance. 3 is the first admin user created, usually.
|
||||
runAddQueriesToMobilizonAPI: true,
|
||||
enableFetch: true, // enable persisting of new events via API
|
||||
// enableFetch: false,
|
||||
dev_mode: true, // dev mode uses localhost instance of mobilizon running on port 4000
|
||||
limit_persistence_of_new_events:true,
|
||||
max_new_events_in_scrapping: 400,
|
||||
max_new_events: 5,
|
||||
bearer_token: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJtb2JpbGl6b24iLCJleHAiOjE2NDIwODIzOTgsImlhdCI6MTY0MjA4MTQ5OCwiaXNzIjoibW9iaWxpem9uIiwianRpIjoiYWQyZjMxY2YtMDUxZi00MmY0LWI1ZDYtMzc4ZjZiOTgxY2EwIiwibmJmIjoxNjQyMDgxNDk3LCJzdWIiOiJVc2VyOjEiLCJ0eXAiOiJhY2Nlc3MifQ.U0JnKQFkklxDcWPE4utXwj65mR0N1LyT3qwC2RzOiWjLWyCS_0KMKJPm5uvylZ-lhiPigojfZsuQCekYL0qTHg",
|
||||
max_new_events: 60,
|
||||
bearer_token: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJtb2JpbGl6b24iLCJleHAiOjE2NDIwODQxMTYsImlhdCI6MTY0MjA4MzIxNiwiaXNzIjoibW9iaWxpem9uIiwianRpIjoiOWRkN2Q5NDUtOWNlMC00Mzk4LTgxOTEtMDgxODk4NWYxZTM4IiwibmJmIjoxNjQyMDgzMjE1LCJzdWIiOiJVc2VyOjEiLCJ0eXAiOiJhY2Nlc3MifQ.PXFYQGUID1VM9cc_C_gNK78qhCIco217B9XN9IAUwHc4sx-FX9y_yrryuAfNwCLXYXfafbVBNMZlMNZ5LnwMcg",
|
||||
|
||||
ccpl: "https://www.cc-paysdelimours.fr/agenda"
|
||||
|
||||
|
@ -35,7 +35,7 @@ async function runImportEvents() {
|
||||
// get json file for ADL
|
||||
await fs.readFile(filepath, 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
return console.log('readFile ERROR', err);
|
||||
}
|
||||
filecontent = JSON.parse(data)
|
||||
filecontent = filecontent.slice(0, parserConfig.max_new_events_in_scrapping)
|
||||
@ -64,8 +64,8 @@ async function runImportEvents() {
|
||||
console.log('nouveaux évènements à ajouter: ', utilsTools.newEvents.length);
|
||||
let limiter = parserConfig.limit_persistence_of_new_events;
|
||||
let counter = 0;
|
||||
let counter_max = parserConfig.max_new_events;
|
||||
|
||||
console.log('utilsTools.localMobilizonEventsByTitle', utilsTools.localMobilizonEventsByTitle);
|
||||
utilsTools.newEvents.forEach((pair: any) => {
|
||||
let graphQLquery = pair.newQuery;
|
||||
|
||||
@ -93,7 +93,7 @@ async function runImportEvents() {
|
||||
console.log('ajouter');
|
||||
// add a little delay between creations
|
||||
|
||||
fetchEvent(url, options, counter, pair.event)
|
||||
fetchEvent(url, options, counter, counter_max, pair.event)
|
||||
} else {
|
||||
console.log('nope');
|
||||
}
|
||||
@ -108,43 +108,43 @@ async function runImportEvents() {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const fetchEvent = (theUrl, theOptions, counter, event) => {
|
||||
let timeout = setTimeout(
|
||||
let timeout;
|
||||
const fetchEvent = (theUrl, theOptions, counter, counter_max, event) => {
|
||||
let BearerIsOK = true;
|
||||
timeout = setTimeout(
|
||||
function () {
|
||||
console.log(counter,'/', counter_max,' fetch start - ' + event.title + ' ' + event.start_time);
|
||||
if(BearerIsOK){
|
||||
|
||||
fetch(theUrl, theOptions)
|
||||
.then((res: any) => {
|
||||
let status = res.status;
|
||||
console.log('status', status);
|
||||
console.log(' status', status);
|
||||
if (status === 401) {
|
||||
console.error(' /!\\ ------------------ ERROR: Bearer token invalid ------------------')
|
||||
|
||||
clearTimeout(timeout);
|
||||
|
||||
} else if (status === 200) {
|
||||
console.log('succès - ' + event.title + ' ' + event.start_time);
|
||||
console.log(' succès - ' + event.title + ' ' + event.start_time);
|
||||
|
||||
}
|
||||
res.json()
|
||||
// console.log(' res', res);
|
||||
return res.json()
|
||||
})
|
||||
.then((json: any) => console.log(json))
|
||||
.catch((err: any) => console.log(err))
|
||||
}
|
||||
.then((json: any) => console.log(counter,'/', counter_max, 'DONE'))
|
||||
.catch((err: any) => {
|
||||
console.log(err)
|
||||
BearerIsOK = false;
|
||||
})
|
||||
|
||||
}
|
||||
}.bind(this)
|
||||
,
|
||||
1000 * counter
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// fs.stat(filepath, function (err, stat) {
|
||||
// if (err == null) {
|
||||
runImportEvents();
|
||||
// } else if (err.code === 'ENOENT') {
|
||||
// // file does not exist
|
||||
// console.log('Scrapped json file does not exist. Run a scraper like "ts-node scrapers/adl.ts" before using this importer: ', err.code);
|
||||
// } else {
|
||||
// console.log('Some other error: ', err.code);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
|
14
utils.ts
14
utils.ts
@ -239,16 +239,16 @@ class utils {
|
||||
variables: {
|
||||
attributedToId: null,
|
||||
beginsOn: event.start_time,
|
||||
contacts: [event.contact],
|
||||
contacts: [],
|
||||
description:
|
||||
|
||||
"<address>" + event.city
|
||||
+ "<br/>"+
|
||||
event.address +
|
||||
"<br/>"+
|
||||
event.place_name +
|
||||
"<address>" +
|
||||
"<span class='city'>"+ event.city+"</span><br/>"+
|
||||
"<span class='address'>"+ event.address+"</span><br/>"+
|
||||
"<span class='place_name'>"+ event.place_name+"</span><br/>"+
|
||||
"</address>"+
|
||||
"<p>" + event.description + "</p>",
|
||||
"<span class='contact'>"+ event.contact+"</span><br/>"+
|
||||
"<p class='event_description'>" + event.description + "</p>",
|
||||
draft: false,
|
||||
endsOn: event.end_time,
|
||||
joinOptions: "FREE",
|
||||
|
Loading…
Reference in New Issue
Block a user