Compare commits
No commits in common. "4e510e57187ead774c1a2b7f15d6cbc17af554d6" and "86aa7bc3aef7a44ea4a833d120ecc286a7f5d77b" have entirely different histories.
4e510e5718
...
86aa7bc3ae
8
configMobilizon.ts
Normal file
8
configMobilizon.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
exports.config = {
|
||||||
|
feeder_mobilizon_user_id: "",
|
||||||
|
db_name: "",
|
||||||
|
db_user: "",
|
||||||
|
db_pass: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
export {};
|
167
index.js
167
index.js
@ -1,69 +1,122 @@
|
|||||||
// @author tykayn contact@cipherbliss.com www.cipherbliss.com
|
// @author tykayn contact@cipherbliss.com www.cipherbliss.com
|
||||||
// imports
|
// imports
|
||||||
import utils from './utils.ts';
|
import utils from "./utils.ts";
|
||||||
import parserConfig from './config.ts';
|
import parserConfig from "./config.ts";
|
||||||
import { htmlEscape } from 'escape-goat';
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import Parser from 'rss-parser';
|
import { htmlEscape } from "escape-goat";
|
||||||
|
import Parser from "rss-parser";
|
||||||
const fetch = require('node-fetch');
|
import { Client } from "pg";
|
||||||
|
const fetch = require("node-fetch");
|
||||||
let parser = new Parser();
|
let parser = new Parser();
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ==============================================='.blue);
|
console.log(" ===============================================".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ==== Rss Feeder for mobilizon - by tykayn ===='.blue);
|
console.log(" ==== Rss Feeder for mobilizon - by tykayn ====".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ==============================================='.blue);
|
console.log(" ===============================================".blue);
|
||||||
if (parserConfig.debug) {
|
if (parserConfig.debug) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log('configMobilizon'.blue, config);
|
console.log("configMobilizon".blue, config);
|
||||||
}
|
}
|
||||||
const utilsTools = new utils();
|
const utilsTools = new utils();
|
||||||
|
|
||||||
|
let localMobilizonEventsByTitle = [];
|
||||||
|
|
||||||
// trouver si un évènement existe déjà par son titre
|
// trouver si un évènement existe déjà par son titre
|
||||||
|
const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
|
||||||
|
const eventAlreadyExists =
|
||||||
|
-1 !== localMobilizonEventsByTitle.indexOf(rssEvent.title);
|
||||||
|
if (!eventAlreadyExists) {
|
||||||
|
if (parserConfig.debug) {
|
||||||
|
console.log("ajouter l event ", htmlEscape(rssEvent.title));
|
||||||
|
}
|
||||||
|
addEventQuery(rssEvent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let createEventQueries = '';
|
let createEventQueries = "";
|
||||||
let counterOfEventsToAdd = 0;
|
let counterOfEventsToAdd = 0;
|
||||||
const addEventQuery = utilsTools.agendadulibre.addQuery;
|
const addEventQuery = (rssEvent) => {
|
||||||
const runCreationQuery = utilsTools.runCreationQuery;
|
if (!createEventQueries) {
|
||||||
|
createEventQueries =
|
||||||
|
"INSERT INTO events(title, description, organizer_actor_id,inserted_at,updated_at, uuid, url, status, category, options,participants_stats, begins_on, ends_on) VALUES ";
|
||||||
|
}
|
||||||
|
if (counterOfEventsToAdd) {
|
||||||
|
createEventQueries += ` , `;
|
||||||
|
}
|
||||||
|
|
||||||
|
let title = "'" + htmlEscape(rssEvent.title) + "'";
|
||||||
|
let content = "'" + htmlEscape(rssEvent.content) + "'";
|
||||||
|
let uuid = uuidv4();
|
||||||
|
let uuidString = "'" + uuid + "'";
|
||||||
|
let eventUrl =
|
||||||
|
"'" + parserConfig.mobilizon_public_url + "/events/" + uuid + "'";
|
||||||
|
let begins_on = "'" + utilsTools.convertRssDate(rssEvent.date) + "'";
|
||||||
|
let ends_on = "'" + utilsTools.convertRssDate(rssEvent.date) + "'";
|
||||||
|
let baseOptions =
|
||||||
|
'{"offers": [], "program": null, "attendees": [], "show_end_time": true, "show_start_time": true, "comment_moderation": "allow_all", "anonymous_participation": true, "participation_condition": [], "show_participation_price": false, "maximum_attendee_capacity": 0, "remaining_attendee_capacity": 0, "hide_organizer_when_group_event": false, "show_remaining_attendee_capacity": false}';
|
||||||
|
let baseStats =
|
||||||
|
'{"creator": 1, "rejected": 0, "moderator": 0, "participant": 0, "not_approved": 0, "administrator": 0, "not_confirmed": 0}';
|
||||||
|
// TODO complete with date conversion
|
||||||
|
// begins_on , ends_on expecting date format like this: "2020-12-17 23:00:00"
|
||||||
|
|
||||||
|
createEventQueries += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats}, ${begins_on} , ${ends_on} )`;
|
||||||
|
|
||||||
|
counterOfEventsToAdd++;
|
||||||
|
};
|
||||||
|
const runCreationQuery = async () => {
|
||||||
|
createEventQueries = createEventQueries + ";";
|
||||||
|
utilsTools.writeFile("event_creation_query.psql", createEventQueries);
|
||||||
|
|
||||||
|
if (createEventQueries) {
|
||||||
|
console.log(" ");
|
||||||
|
console.log(" ⚙️⚙️⚙️ ");
|
||||||
|
console.log(" ");
|
||||||
|
console.log(" createEventQueries");
|
||||||
|
console.log(createEventQueries);
|
||||||
|
|
||||||
|
const res = await client.query(createEventQueries);
|
||||||
|
console.log("res", res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
host: "localhost",
|
||||||
|
user: parserConfig.db_user,
|
||||||
|
password: parserConfig.db_pass,
|
||||||
|
database: parserConfig.db_name,
|
||||||
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.log('⌛ interroger la BDD mobilizon postgresql');
|
console.log("⌛ interroger la BDD mobilizon postgresql");
|
||||||
|
|
||||||
utilsTools.setupClientPostgresql();
|
await client.connect();
|
||||||
|
console.log("✅ OK connecté à postgresql");
|
||||||
|
console.log(" ");
|
||||||
|
const res = await client.query("SELECT * from events");
|
||||||
|
console.log("💾 évènements enregistrés dans mobilizon : ", res.rows.length); // Hello world!
|
||||||
|
|
||||||
await utilsTools.client.connect();
|
utilsTools.postgresEventsExisting = res.rows;
|
||||||
console.log('✅ OK connecté à postgresql');
|
|
||||||
console.log(' ');
|
|
||||||
const res = await utilsTools.client.query('SELECT * from events');
|
|
||||||
console.log('💾 évènements enregistrés dans mobilizon : ', res.rows.length); // Hello world!
|
|
||||||
|
|
||||||
utilsTools.localMobilizonEventsByTitle = res.rows;
|
|
||||||
|
|
||||||
if (parserConfig.askAgendaDuLibre) {
|
if (parserConfig.askAgendaDuLibre) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ===================================================='.blue);
|
console.log(" ====================================================".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
|
console.log(" ==== demander à l'agenda du libre son flux RSS ====".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ===================================================='.blue);
|
console.log(" ====================================================".blue);
|
||||||
|
|
||||||
console.log('⌛ lecture du flux rss : ' + parserConfig.rss_feed_url);
|
|
||||||
fetch(parserConfig.rss_feed_url, { method: 'GET' })
|
|
||||||
|
|
||||||
.then((arrayOfEvents) => {
|
|
||||||
console.log('xml rss_feed_url count', arrayOfEvents.length);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
console.log("⌛ lecture du flux rss : " + parserConfig.rss_feed_url);
|
||||||
let feed = await parser.parseURL(parserConfig.rss_feed_url);
|
let feed = await parser.parseURL(parserConfig.rss_feed_url);
|
||||||
console.log('✅ flux rss obtenu');
|
console.log("✅ flux rss obtenu");
|
||||||
|
utilsTools.writeFile("agenda_du_libre_feed.xml", feed);
|
||||||
console.log(feed.title);
|
console.log(feed.title);
|
||||||
|
|
||||||
console.log('⚙️ interprétation des évènements');
|
console.log("⚙️ interprétation des évènements");
|
||||||
console.log(
|
console.log(
|
||||||
'⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql',
|
"⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql"
|
||||||
);
|
);
|
||||||
feed.items.forEach((eventFound) => {
|
feed.items.forEach((eventFound) => {
|
||||||
console.log(eventFound.title);
|
console.log(eventFound.title);
|
||||||
@ -73,50 +126,46 @@ const runCreationQuery = utilsTools.runCreationQuery;
|
|||||||
}
|
}
|
||||||
if (parserConfig.askOsmCal) {
|
if (parserConfig.askOsmCal) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ===================================================='.blue);
|
console.log(" ====================================================".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ==== demander à OSM cal ===='.blue);
|
console.log(" ==== demander à OSM cal ====".blue);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ===================================================='.blue);
|
console.log(" ====================================================".blue);
|
||||||
|
|
||||||
fetch(parserConfig.osmcal_url, { method: 'GET' })
|
fetch(parserConfig.osmcal_url, { method: "GET" })
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((arrayOfEvents) => {
|
.then((arrayOfEvents) => {
|
||||||
console.log('json osmcal count', arrayOfEvents.length);
|
console.log("json osmcal count", arrayOfEvents.length);
|
||||||
|
|
||||||
utilsTools.writeFile('osmcal.json', arrayOfEvents, 'json');
|
utilsTools.writeFile("osmcal.json", arrayOfEvents);
|
||||||
|
|
||||||
console.log('arrayOfEvents[0]', arrayOfEvents[1])
|
arrayOfEvents.forEach((eventFound) => {
|
||||||
utilsTools.osmcal.doesEventExists(arrayOfEvents[1])
|
console.log(eventFound.name);
|
||||||
|
// console.log('item', item)
|
||||||
// arrayOfEvents.forEach((eventFound) => {
|
utilsTools.osmCal.doesEventExists(eventFound);
|
||||||
// utilsTools.osmcal.doesEventExists(eventFound);
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parserConfig.runAddQueriesToMobilizon) {
|
if (parserConfig.runAddQueriesToMobilizon) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(
|
console.log(
|
||||||
'➕ rajouter les évènements manquants à la base mobilizon'.blue,
|
"➕ rajouter les évènements manquants à la base mobilizon".blue
|
||||||
);
|
);
|
||||||
|
|
||||||
utilsTools.makeQuery();
|
await runCreationQuery();
|
||||||
utilsTools.runCreationQuery();
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ---------- '.green);
|
console.log(" ---------- ".green);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(counterOfEventsToAdd, ' évènements ajoutés '.green);
|
console.log(counterOfEventsToAdd, " évènements ajoutés ".green);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log(' ---------- '.green);
|
console.log(" ---------- ".green);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log('✅ fermer la connec postgresql');
|
console.log("✅ ça c'est fait ".green);
|
||||||
await utilsTools.client.end();
|
|
||||||
console.log('✅ ça c\'est fait '.green);
|
|
||||||
}
|
}
|
||||||
|
await client.end();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
exports = () => {
|
exports = () => {
|
||||||
console.log('✅ hey ho', this);
|
console.log("hey ho", this);
|
||||||
};
|
};
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"place_id": 257545391,
|
|
||||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
|
||||||
"osm_type": "relation",
|
|
||||||
"osm_id": 5753651,
|
|
||||||
"lat": "11.8447153",
|
|
||||||
"lon": "1.8991527451060923",
|
|
||||||
"display_name": "Tansarga, Tapoa, Est, Burkina Faso",
|
|
||||||
"address": {
|
|
||||||
"department": "Tansarga",
|
|
||||||
"province": "Tapoa",
|
|
||||||
"region": "Est",
|
|
||||||
"country": "Burkina Faso",
|
|
||||||
"country_code": "bf"
|
|
||||||
},
|
|
||||||
"boundingbox": [
|
|
||||||
"11.6508914",
|
|
||||||
"12.0385474",
|
|
||||||
"1.7610148",
|
|
||||||
"2.0502629"
|
|
||||||
]
|
|
||||||
}
|
|
@ -22,10 +22,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Oberframmering, Landau an der Isar, Bavaria, Germany",
|
"short": "Oberframmering, Landau an der Isar, Bavaria, Germany",
|
||||||
"detailed": "online, Osterhofener Straße, Oberframmering, Bavaria, Germany",
|
"detailed": "online, Osterhofener Straße, Oberframmering, Bavaria, Germany",
|
||||||
"coords": [
|
"coords": [12.749539, 48.688166],
|
||||||
12.749539,
|
|
||||||
48.688166
|
|
||||||
],
|
|
||||||
"venue": "online"
|
"venue": "online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -42,10 +39,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "San Jose, California, United States",
|
"short": "San Jose, California, United States",
|
||||||
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
||||||
"coords": [
|
"coords": [-121.890583, 37.336191],
|
||||||
-121.890583,
|
|
||||||
37.336191
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -61,10 +55,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Bochum, North Rhine-Westphalia, Germany",
|
"short": "Bochum, North Rhine-Westphalia, Germany",
|
||||||
"detailed": "Jitsi, Boulevard, Innenstadt, Bochum, North Rhine-Westphalia, Germany",
|
"detailed": "Jitsi, Boulevard, Innenstadt, Bochum, North Rhine-Westphalia, Germany",
|
||||||
"coords": [
|
"coords": [7.219664, 51.481811],
|
||||||
7.219664,
|
|
||||||
51.481811
|
|
||||||
],
|
|
||||||
"venue": "Jitsi"
|
"venue": "Jitsi"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -80,10 +71,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Dresden, Saxony, Germany",
|
"short": "Dresden, Saxony, Germany",
|
||||||
"detailed": "Online, Wilsdruffer Straße, Innere Altstadt, Dresden, Saxony, Germany",
|
"detailed": "Online, Wilsdruffer Straße, Innere Altstadt, Dresden, Saxony, Germany",
|
||||||
"coords": [
|
"coords": [13.738144, 51.049329],
|
||||||
13.738144,
|
|
||||||
51.049329
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -100,10 +88,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Warsaw, Masovian Voivodeship, Poland",
|
"short": "Warsaw, Masovian Voivodeship, Poland",
|
||||||
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
||||||
"coords": [
|
"coords": [21.006725, 52.231958],
|
||||||
21.006725,
|
|
||||||
52.231958
|
|
||||||
],
|
|
||||||
"venue": "Poland"
|
"venue": "Poland"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -119,10 +104,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Großarl, Salzburg, Austria",
|
"short": "Großarl, Salzburg, Austria",
|
||||||
"detailed": "Online, Ebengasse, Salzburg, Austria",
|
"detailed": "Online, Ebengasse, Salzburg, Austria",
|
||||||
"coords": [
|
"coords": [13.199959, 47.200034],
|
||||||
13.199959,
|
|
||||||
47.200034
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -149,10 +131,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Tamia, Madhya Pradesh, India",
|
"short": "Tamia, Madhya Pradesh, India",
|
||||||
"detailed": "India, Tamia, Madhya Pradesh, India",
|
"detailed": "India, Tamia, Madhya Pradesh, India",
|
||||||
"coords": [
|
"coords": [78.667743, 22.351115],
|
||||||
78.667743,
|
|
||||||
22.351115
|
|
||||||
],
|
|
||||||
"venue": "India"
|
"venue": "India"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -169,10 +148,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "online bbb, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "online bbb, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "online bbb"
|
"venue": "online bbb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -188,10 +164,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Munich, Bavaria, Germany",
|
"short": "Munich, Bavaria, Germany",
|
||||||
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
||||||
"coords": [
|
"coords": [11.575382, 48.137108]
|
||||||
11.575382,
|
|
||||||
48.137108
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -207,10 +180,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Michigan, United States",
|
"short": "Michigan, United States",
|
||||||
"detailed": "Online, Chippewa Trail, Michigan, United States",
|
"detailed": "Online, Chippewa Trail, Michigan, United States",
|
||||||
"coords": [
|
"coords": [-84.682435, 43.621196],
|
||||||
-84.682435,
|
|
||||||
43.621196
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -227,10 +197,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Kansas, United States",
|
"short": "Kansas, United States",
|
||||||
"detailed": "Online, County Road 412, Kansas, United States",
|
"detailed": "Online, County Road 412, Kansas, United States",
|
||||||
"coords": [
|
"coords": [-98.550441, 39.224396],
|
||||||
-98.550441,
|
|
||||||
39.224396
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -246,10 +213,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Berlin, Berlin, Germany",
|
"short": "Berlin, Berlin, Germany",
|
||||||
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
||||||
"coords": [
|
"coords": [13.38886, 52.517037],
|
||||||
13.38886,
|
|
||||||
52.517037
|
|
||||||
],
|
|
||||||
"venue": "Online, Link zur Platform siehe Event-Website"
|
"venue": "Online, Link zur Platform siehe Event-Website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -266,10 +230,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Warsaw, Masovian Voivodeship, Poland",
|
"short": "Warsaw, Masovian Voivodeship, Poland",
|
||||||
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
||||||
"coords": [
|
"coords": [21.006725, 52.231958],
|
||||||
21.006725,
|
|
||||||
52.231958
|
|
||||||
],
|
|
||||||
"venue": "Poland"
|
"venue": "Poland"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -285,10 +246,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lyon, Auvergne-Rhône-Alpes, France",
|
"short": "Lyon, Auvergne-Rhône-Alpes, France",
|
||||||
"detailed": "online, Rue Juliette Récamier, Les Brotteaux, Lyon, Auvergne-Rhône-Alpes, France",
|
"detailed": "online, Rue Juliette Récamier, Les Brotteaux, Lyon, Auvergne-Rhône-Alpes, France",
|
||||||
"coords": [
|
"coords": [4.853832, 45.763808],
|
||||||
4.853832,
|
|
||||||
45.763808
|
|
||||||
],
|
|
||||||
"venue": "online"
|
"venue": "online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -325,10 +283,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Berlin, Berlin, Germany",
|
"short": "Berlin, Berlin, Germany",
|
||||||
"detailed": "Online, Link zur Platform siehe Wiki-Link, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
"detailed": "Online, Link zur Platform siehe Wiki-Link, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
||||||
"coords": [
|
"coords": [13.38886, 52.517037],
|
||||||
13.38886,
|
|
||||||
52.517037
|
|
||||||
],
|
|
||||||
"venue": "Online, Link zur Platform siehe Wiki-Link"
|
"venue": "Online, Link zur Platform siehe Wiki-Link"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -344,10 +299,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -363,10 +315,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "San Jose, California, United States",
|
"short": "San Jose, California, United States",
|
||||||
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
||||||
"coords": [
|
"coords": [-121.890583, 37.336191],
|
||||||
-121.890583,
|
|
||||||
37.336191
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -383,10 +332,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Warsaw, Masovian Voivodeship, Poland",
|
"short": "Warsaw, Masovian Voivodeship, Poland",
|
||||||
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
||||||
"coords": [
|
"coords": [21.006725, 52.231958],
|
||||||
21.006725,
|
|
||||||
52.231958
|
|
||||||
],
|
|
||||||
"venue": "Poland"
|
"venue": "Poland"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -402,10 +348,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Bremen, Free Hanseatic City of Bremen, Germany",
|
"short": "Bremen, Free Hanseatic City of Bremen, Germany",
|
||||||
"detailed": "Online via Jitsi, Am Markt, Mitte, Bremen, Free Hanseatic City of Bremen, Germany",
|
"detailed": "Online via Jitsi, Am Markt, Mitte, Bremen, Free Hanseatic City of Bremen, Germany",
|
||||||
"coords": [
|
"coords": [8.807165, 53.07582],
|
||||||
8.807165,
|
|
||||||
53.07582
|
|
||||||
],
|
|
||||||
"venue": "Online via Jitsi"
|
"venue": "Online via Jitsi"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -422,10 +365,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Brussels, Brussels-Capital, Belgium",
|
"short": "Brussels, Brussels-Capital, Belgium",
|
||||||
"detailed": "Online, 8, Grand Place, Brussels, Brussels-Capital, Belgium",
|
"detailed": "Online, 8, Grand Place, Brussels, Brussels-Capital, Belgium",
|
||||||
"coords": [
|
"coords": [4.351697, 50.846557],
|
||||||
4.351697,
|
|
||||||
50.846557
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -442,10 +382,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Warsaw, Masovian Voivodeship, Poland",
|
"short": "Warsaw, Masovian Voivodeship, Poland",
|
||||||
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
"detailed": "Poland, 1, Plac Defilad, Śródmieście, Warsaw, Masovian Voivodeship, Poland",
|
||||||
"coords": [
|
"coords": [21.006725, 52.231958],
|
||||||
21.006725,
|
|
||||||
52.231958
|
|
||||||
],
|
|
||||||
"venue": "Poland"
|
"venue": "Poland"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -462,10 +399,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "San Jose, California, United States",
|
"short": "San Jose, California, United States",
|
||||||
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
"detailed": "Online, East Santa Clara Street, Japantown, San Jose, California, United States",
|
||||||
"coords": [
|
"coords": [-121.890583, 37.336191],
|
||||||
-121.890583,
|
|
||||||
37.336191
|
|
||||||
],
|
|
||||||
"venue": "Online"
|
"venue": "Online"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -481,10 +415,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Munich, Bavaria, Germany",
|
"short": "Munich, Bavaria, Germany",
|
||||||
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
||||||
"coords": [
|
"coords": [11.575382, 48.137108]
|
||||||
11.575382,
|
|
||||||
48.137108
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -500,10 +431,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "online bbb, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "online bbb, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "online bbb"
|
"venue": "online bbb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -519,10 +447,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Berlin, Berlin, Germany",
|
"short": "Berlin, Berlin, Germany",
|
||||||
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
||||||
"coords": [
|
"coords": [13.38886, 52.517037],
|
||||||
13.38886,
|
|
||||||
52.517037
|
|
||||||
],
|
|
||||||
"venue": "Online, Link zur Platform siehe Event-Website"
|
"venue": "Online, Link zur Platform siehe Event-Website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -548,10 +473,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -567,10 +489,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "online oder cafe BQM, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "online oder cafe BQM, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "online oder cafe BQM"
|
"venue": "online oder cafe BQM"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -586,10 +505,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Munich, Bavaria, Germany",
|
"short": "Munich, Bavaria, Germany",
|
||||||
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
"detailed": "Thiereckstraße, Altstadt-Lehel, Munich, Bavaria, Germany",
|
||||||
"coords": [
|
"coords": [11.575382, 48.137108]
|
||||||
11.575382,
|
|
||||||
48.137108
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -604,10 +520,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Berlin, Berlin, Germany",
|
"short": "Berlin, Berlin, Germany",
|
||||||
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
"detailed": "Online, Link zur Platform siehe Event-Website, Unter den Linden, Mitte, Berlin, Berlin, Germany",
|
||||||
"coords": [
|
"coords": [13.38886, 52.517037],
|
||||||
13.38886,
|
|
||||||
52.517037
|
|
||||||
],
|
|
||||||
"venue": "Online, Link zur Platform siehe Event-Website"
|
"venue": "Online, Link zur Platform siehe Event-Website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -633,10 +546,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -651,10 +561,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -680,10 +587,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -699,10 +603,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -727,10 +628,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Lüneburg, Lower Saxony, Germany",
|
"short": "Lüneburg, Lower Saxony, Germany",
|
||||||
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
"detailed": "9, Friedenstraße, Rotes Feld, Lower Saxony, Germany",
|
||||||
"coords": [
|
"coords": [10.412018, 53.245632]
|
||||||
10.412018,
|
|
||||||
53.245632
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -756,10 +654,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -776,10 +671,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -796,10 +688,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Zurich, Zurich, Switzerland",
|
"short": "Zurich, Zurich, Switzerland",
|
||||||
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
"detailed": "beim Studi-Café bQm (ETH), Zürich, Hochstrasse, Fluntern, Zurich, Zurich, Switzerland",
|
||||||
"coords": [
|
"coords": [8.546741, 47.376035],
|
||||||
8.546741,
|
|
||||||
47.376035
|
|
||||||
],
|
|
||||||
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
"venue": "beim Studi-Café bQm (ETH), Zürich"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -816,10 +705,7 @@
|
|||||||
"location": {
|
"location": {
|
||||||
"short": "Nairobi, Nairobi, Kenya",
|
"short": "Nairobi, Nairobi, Kenya",
|
||||||
"detailed": "Nairobi, Kenya, Uhuru Highway, Nairobi West, Nairobi, Nairobi, Kenya",
|
"detailed": "Nairobi, Kenya, Uhuru Highway, Nairobi West, Nairobi, Nairobi, Kenya",
|
||||||
"coords": [
|
"coords": [36.826061, -1.303169],
|
||||||
36.826061,
|
|
||||||
-1.303169
|
|
||||||
],
|
|
||||||
"venue": "Nairobi, Kenya"
|
"venue": "Nairobi, Kenya"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
182
utils.ts
182
utils.ts
@ -1,55 +1,8 @@
|
|||||||
// @ts-ignore
|
|
||||||
import parserConfig from "./config.ts";
|
|
||||||
import {v4 as uuidv4} from "uuid";
|
|
||||||
import {Client} from "pg";
|
|
||||||
import {htmlEscape} from "escape-goat";
|
|
||||||
|
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
class utils {
|
class utils {
|
||||||
|
|
||||||
/**
|
|
||||||
* postgres functions
|
|
||||||
*/
|
|
||||||
client;
|
|
||||||
makeQuery = () => {
|
|
||||||
this.createEventQueries = `INSERT INTO events(title, description, organizer_actor_id,inserted_at,updated_at, uuid, url, status, category, options,participants_stats, begins_on, ends_on) VALUES ${this.agendadulibre.queryToAdd} ${this.osmcal.queryToAdd};`;
|
|
||||||
this.writeFile("event_creation_query.psql", this.createEventQueries, "psql");
|
|
||||||
}
|
|
||||||
runCreationQuery = async () => {
|
|
||||||
if (this.createEventQueries) {
|
|
||||||
console.log(" ");
|
|
||||||
console.log(" ⚙️⚙️⚙️ ");
|
|
||||||
console.log(" ");
|
|
||||||
console.log(" createEventQueries");
|
|
||||||
console.log(this.createEventQueries);
|
|
||||||
|
|
||||||
const res = await this.client.query(this.createEventQueries);
|
|
||||||
console.log("res", res);
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
console.log(" DISABLED createEventQueries");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* memorizing properties
|
|
||||||
*/
|
|
||||||
createEventQueries = "";
|
|
||||||
counterOfEventsToAdd = 0;
|
|
||||||
localMobilizonEventsByTitle = [];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converters
|
|
||||||
*/
|
|
||||||
|
|
||||||
geocoderNominatim(coords){
|
|
||||||
// https://nominatim.openstreetmap.org/reverse?lat=<value>&lon=<value>&<params>
|
|
||||||
console.log('https://nominatim.openstreetmap.org/reverse?lat='+coords[0]+'&lon='+coords[0])+'&format=json'
|
|
||||||
}
|
|
||||||
convertRssDate(rssDate) {
|
convertRssDate(rssDate) {
|
||||||
let converted = moment(rssDate)
|
let converted = moment(rssDate)
|
||||||
.format("YYYY-MM-DD LTS")
|
.format("YYYY-MM-DD LTS")
|
||||||
@ -61,34 +14,17 @@ class utils {
|
|||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertCoordinateLinkOsmCal(coords) {
|
|
||||||
|
|
||||||
|
|
||||||
this.geocoderNominatim(coords);
|
|
||||||
|
|
||||||
return ` <div class='coordinates'>
|
|
||||||
<a href='https://www.openstreetmap.org/directions?from=&to=${coords[0]}%2C${coords[1]}'>voir le lieu sur une carte
|
|
||||||
</a>
|
|
||||||
</div> `
|
|
||||||
}
|
|
||||||
|
|
||||||
testdateconvert() {
|
testdateconvert() {
|
||||||
let converted = this.convertRssDate("2021-03-12T19:00:00Z");
|
let converted = this.convertRssDate("2021-03-12T19:00:00Z");
|
||||||
console.log("converted", converted);
|
console.log("converted", converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
postgresEventsExisting = [];
|
||||||
* file management
|
writeFile = (fileName, data) => {
|
||||||
*/
|
|
||||||
writeFile = (fileName, data, formatData) => {
|
|
||||||
let dataToSave = data;
|
|
||||||
if (formatData == 'json') {
|
|
||||||
dataToSave = JSON.stringify(data, null, 4)
|
|
||||||
}
|
|
||||||
// write file to disk
|
// write file to disk
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
`./sources_examples/${fileName}`,
|
`./sources_examples/${fileName}`,
|
||||||
dataToSave,
|
JSON.stringify(data),
|
||||||
"utf8",
|
"utf8",
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -99,118 +35,16 @@ class utils {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
osmCal = {
|
||||||
/** ==============================
|
|
||||||
* importation sources
|
|
||||||
*/
|
|
||||||
|
|
||||||
osmcal = {
|
|
||||||
queryToAdd: "",
|
queryToAdd: "",
|
||||||
counterOfEventsToAdd: 0,
|
doesEventExists: (event) => {},
|
||||||
getTitle: (event) => {
|
addQuery: (event) => {},
|
||||||
return event.name;
|
|
||||||
//+ ' '+ event.location.short
|
|
||||||
},
|
|
||||||
doesEventExists: (event) => {
|
|
||||||
const eventAlreadyExists =
|
|
||||||
-1 !== this.localMobilizonEventsByTitle.indexOf(this.osmcal.getTitle(event));
|
|
||||||
if (!eventAlreadyExists) {
|
|
||||||
if (parserConfig.debug) {
|
|
||||||
console.log('ajouter l event ', htmlEscape(this.osmcal.getTitle(event)));
|
|
||||||
}
|
|
||||||
this.osmcal.addQuery(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
addQuery: (event) => {
|
|
||||||
|
|
||||||
if (this.osmcal.queryToAdd) {
|
|
||||||
this.osmcal.queryToAdd += ` , `;
|
|
||||||
}
|
|
||||||
let title = "'" + htmlEscape(this.osmcal.getTitle(event)) + "'";
|
|
||||||
let content = "'" + htmlEscape(`${event.date.human} <br/>${+event.url} <br/> `) + "'";
|
|
||||||
|
|
||||||
if (event.location) {
|
|
||||||
content += `${event.location.detailed} `
|
|
||||||
if (event.location.venue) {
|
|
||||||
content += ` <br/>
|
|
||||||
${event.location.venue}`
|
|
||||||
}
|
|
||||||
if (event.location.coords) {
|
|
||||||
content += ` <br/> ` + this.convertCoordinateLinkOsmCal(event.location.coords)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(' ')
|
|
||||||
console.log(' title', title)
|
|
||||||
console.log(' content', content)
|
|
||||||
|
|
||||||
let uuid = uuidv4();
|
|
||||||
let uuidString = "'" + uuid + "'";
|
|
||||||
let eventUrl =
|
|
||||||
"'" + parserConfig.mobilizon_public_url + "/events/" + uuid + "'";
|
|
||||||
let begins_on = "'" + this.convertRssDate(event.date.start) + "'";
|
|
||||||
let ends_on = "'" + this.convertRssDate(event.date.end) + "'";
|
|
||||||
let baseOptions =
|
|
||||||
'{"offers": [], "program": null, "attendees": [], "show_end_time": true, "show_start_time": true, "comment_moderation": "allow_all", "anonymous_participation": true, "participation_condition": [], "show_participation_price": false, "maximum_attendee_capacity": 0, "remaining_attendee_capacity": 0, "hide_organizer_when_group_event": false, "show_remaining_attendee_capacity": false}';
|
|
||||||
let baseStats =
|
|
||||||
'{"creator": 1, "rejected": 0, "moderator": 0, "participant": 0, "not_approved": 0, "administrator": 0, "not_confirmed": 0}';
|
|
||||||
// begins_on , ends_on expecting date format like this: "2020-12-17 23:00:00"
|
|
||||||
|
|
||||||
this.osmcal.queryToAdd += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats}, ${begins_on} , ${ends_on} )`;
|
|
||||||
|
|
||||||
|
|
||||||
this.osmcal.counterOfEventsToAdd++;
|
|
||||||
this.counterOfEventsToAdd++;
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
agendadulibre = {
|
agendadulibre = {
|
||||||
queryToAdd: "",
|
queryToAdd: "",
|
||||||
counterOfEventsToAdd: 0,
|
doesEventExists: (event) => {},
|
||||||
doesEventExists: (event) => {
|
addQuery: (event) => {},
|
||||||
const eventAlreadyExists =
|
|
||||||
-1 !== this.localMobilizonEventsByTitle.indexOf(event.title);
|
|
||||||
if (!eventAlreadyExists) {
|
|
||||||
if (parserConfig.debug) {
|
|
||||||
console.log('ajouter l event ', htmlEscape(event.title));
|
|
||||||
}
|
|
||||||
this.agendadulibre.addQuery(event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addQuery: (event) => {
|
|
||||||
if (this.agendadulibre.queryToAdd) {
|
|
||||||
this.agendadulibre.queryToAdd += ` , `;
|
|
||||||
}
|
|
||||||
|
|
||||||
let title = "'" + htmlEscape(event.title) + "'";
|
|
||||||
let content = "'" + htmlEscape(event.content) + "'";
|
|
||||||
let uuid = uuidv4();
|
|
||||||
let uuidString = "'" + uuid + "'";
|
|
||||||
let eventUrl =
|
|
||||||
"'" + parserConfig.mobilizon_public_url + "/events/" + uuid + "'";
|
|
||||||
let begins_on = "'" + this.convertRssDate(event.date) + "'";
|
|
||||||
let ends_on = "'" + this.convertRssDate(event.date) + "'";
|
|
||||||
let baseOptions =
|
|
||||||
'{"offers": [], "program": null, "attendees": [], "show_end_time": true, "show_start_time": true, "comment_moderation": "allow_all", "anonymous_participation": true, "participation_condition": [], "show_participation_price": false, "maximum_attendee_capacity": 0, "remaining_attendee_capacity": 0, "hide_organizer_when_group_event": false, "show_remaining_attendee_capacity": false}';
|
|
||||||
let baseStats =
|
|
||||||
'{"creator": 1, "rejected": 0, "moderator": 0, "participant": 0, "not_approved": 0, "administrator": 0, "not_confirmed": 0}';
|
|
||||||
// begins_on , ends_on expecting date format like this: "2020-12-17 23:00:00"
|
|
||||||
|
|
||||||
this.agendadulibre.queryToAdd += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats}, ${begins_on} , ${ends_on} )`;
|
|
||||||
|
|
||||||
this.agendadulibre.counterOfEventsToAdd++;
|
|
||||||
this.counterOfEventsToAdd++;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setupClientPostgresql = () => {
|
|
||||||
this.client = new Client({
|
|
||||||
host: "localhost",
|
|
||||||
user: parserConfig.db_user,
|
|
||||||
password: parserConfig.db_pass,
|
|
||||||
database: parserConfig.db_name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default utils;
|
export default utils;
|
||||||
|
Loading…
Reference in New Issue
Block a user