working on date conversion with momentjs

master
tykayn 2 years ago committed by Baptiste Lemoine
parent 3620d7c081
commit f6393429f2
  1. 6
      index.js
  2. BIN
      node_modules/.cache/esm/.data.blob
  3. 2
      node_modules/.cache/esm/.data.json
  4. 18
      node_modules/.cache/esm/3ef8332650409682.js
  5. 13
      node_modules/.cache/esm/3ef83326c93bb5f0.js
  6. 56
      node_modules/.cache/esm/4a214f03e9b6dca2.js
  7. 11
      utils.ts

@ -24,9 +24,13 @@ if (parserConfig.debug) {
// @ts-ignore
console.log('configMobilizon'.blue, config);
}
const utilsTools = new utils();
let localMobilizonEventsByTitle = [];
utilsTools.testdateconvert();
// trouver si un évènement existe déjà par son titre
// TODO à affiner au delà du titre
const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
@ -58,7 +62,7 @@ const addEventQuery = (rssEvent) => {
let uuidString = '\'' + uuid + '\'';
let eventUrl = '\'' + parserConfig.mobilizon_public_url + '/events/' + uuid + '\'';
let begins_on = '\'' + uuid + '\'';
let ends_on = '\'' + utils.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 =

BIN
node_modules/.cache/esm/.data.blob generated vendored

Binary file not shown.

@ -1 +1 @@
{"meta":{"4a214f0323c5b60c.js":[0,7840,17,1609701952657,2,null,null,"../../../index.js",-1,469],"3ef83326c93bb5f0.js":[7840,9632,4,1609702268191,2,null,null,"../../../utils.ts",0,35],"4a214f036c2197a3.js":[9632,18832,17,1609702305847,2,null,null,"../../../index.js",0,472],"8bd6d8bafed72c02.js":[18832,20912,4,1609702292217,2,null,null,"../../../config.ts",0,35],"4ea918b634e7ddee.js":[20912,79016],"cfe8e44034e7ddee.js":[79016,82488],"b4a6e37534e7ddee.js":[82488,83856],"1e05fd5334e7ddee.js":[83856,85064],"bf10b4f234e7ddee.js":[85064,86400],"8f40bea234e7ddee.js":[86400,87512],"7e09912634e7ddee.js":[87512,88504],"2674ff5934e7ddee.js":[88504,89592],"8998963e34e7ddee.js":[89592,91136],"502bd04b34e7ddee.js":[91136,92256],"66c70c9d34e7ddee.js":[92256,93352],"8f1bb44f34e7ddee.js":[93352,94544],"434e4b9234e7ddee.js":[94544,95640],"cda6849f34e7ddee.js":[95640,96744],"e3420b7d34e7ddee.js":[96744,97648],"8b712e7434e7ddee.js":[97648,98768],"2053138034e7ddee.js":[98768,99896],"c582ecc634e7ddee.js":[99896,100672],"0bac123734e7ddee.js":[100672,103384],"1c7694f234e7ddee.js":[103384,105408],"5faa8dc034e7ddee.js":[105408,107848],"97c0385c34e7ddee.js":[107848,109936],"36df28f334e7ddee.js":[109936,112432],"eb69a67234e7ddee.js":[112432,114360],"5cfbe43834e7ddee.js":[114360,116592],"49f59e8a34e7ddee.js":[116592,127104],"d51c7bf134e7ddee.js":[127104,129496],"8a2f4c9c34e7ddee.js":[129496,131024],"10f0948334e7ddee.js":[131024,132976],"05b6411534e7ddee.js":[132976,149592],"e63a0d4134e7ddee.js":[149592,151264],"665d971034e7ddee.js":[151264,157112],"506d4c4234e7ddee.js":[157112,158936],"bc5923d134e7ddee.js":[158936,164960],"06f7b82c34e7ddee.js":[164960,166944],"c8b25ccd34e7ddee.js":[166944,172904],"1f5433a534e7ddee.js":[172904,174784],"e5bd35c434e7ddee.js":[174784,178496],"8e4a9ef134e7ddee.js":[178496,180376],"82c6418834e7ddee.js":[180376,182840],"0f45284634e7ddee.js":[182840,185816],"a46ec2ab34e7ddee.js":[185816,187880],"581626d034e7ddee.js":[187880,192080],"91804a3134e7ddee.js":[192080,194152],"6ab8978a34e7ddee.js":[194152,203800],"f875f50734e7ddee.js":[203800,208160],"93569bf434e7ddee.js":[208160,210208],"e76687d634e7ddee.js":[210208,213264],"112ad7a934e7ddee.js":[213264,215568],"d7317d4034e7ddee.js":[215568,217624],"20cf856b34e7ddee.js":[217624,218808],"4b5cde3834e7ddee.js":[218808,229632],"3d32dce434e7ddee.js":[229632,234216],"54a236fc34e7ddee.js":[234216,237776],"0284fc9e1e0f713c.js":[237776,255568],"a8f15fcc34e7ddee.js":[255568,256704],"b0a2f5d334e7ddee.js":[256704,258456],"135aeb1534e7ddee.js":[258456,260976],"3aed101f34e7ddee.js":[260976,263320],"67a658bc34e7ddee.js":[263320,267520],"92b7bd0d34e7ddee.js":[267520,270280],"51a1bfca34e7ddee.js":[270280,271432],"8b76f93b34e7ddee.js":[271432,273432],"e5dbf4c734e7ddee.js":[273432,275008],"75cfb7f334e7ddee.js":[275008,280240],"3850b3a734e7ddee.js":[280240,282168],"b771994234e7ddee.js":[282168,284344],"8785e88234e7ddee.js":[284344,285920],"7ce9446134e7ddee.js":[285920,288984],"0551020634e7ddee.js":[288984,290800],"4cbe626c34e7ddee.js":[290800,291856],"bbae285f34e7ddee.js":[291856,293416],"920f6c777d217eb1.js":[293416,296328],"6f58dc5534e7ddee.js":[296328,297232],"0cc3bc0992c47e23.js":[297232,298064],"a474b7b434e7ddee.js":[298064,300208],"972b86bf4a371210.js":[300208,301072],"cd8930bc34e7ddee.js":[301072,303704],"0eafaf3234e7ddee.js":[303704,305240],"0caa99b934e7ddee.js":[305240,306320],"d29740ff34e7ddee.js":[306320,309800],"f693a2a834e7ddee.js":[309800,311320],"00f4096434e7ddee.js":[311320,313000],"66e222ca34e7ddee.js":[313000,321208],"b6f27b6b34e7ddee.js":[321208,322016],"4618d65334e7ddee.js":[322016,323848],"47ec677034e7ddee.js":[323848,325232],"a6a949ec34e7ddee.js":[325232,326368],"3a7392a334e7ddee.js":[326368,328880],"a5de0d2834e7ddee.js":[328880,329864],"b4cc734134e7ddee.js":[329864,337112],"d3dc197e6408243f.js":[337112,337928],"6457305334e7ddee.js":[337928,340112],"2681d3c834e7ddee.js":[340112,342384],"4527f91e34e7ddee.js":[342384,343544],"af5182ed34e7ddee.js":[343544,344920],"357b6f0e34e7ddee.js":[344920,346728],"89a48c1c34e7ddee.js":[346728,348000],"e0279dc834e7ddee.js":[348000,349752],"787a006e34e7ddee.js":[349752,350704],"ebf2880534e7ddee.js":[350704,353416],"c8e1dfdc34e7ddee.js":[353416,355064],"4390ae1534e7ddee.js":[355064,358664],"8d2da48134e7ddee.js":[358664,359872],"5f16e98b34e7ddee.js":[359872,364960],"4fbbd02934e7ddee.js":[364960,368968],"f0b51d8e34e7ddee.js":[368968,370816],"06b5860134e7ddee.js":[370816,374312],"52a3a93334e7ddee.js":[374312,376224],"d8594d5534e7ddee.js":[376224,379760]},"version":"3.2.25"}
{"meta":{"4a214f0323c5b60c.js":[0,7840,17,1609701952657,2,null,null,"../../../index.js",-1,469],"3ef83326c93bb5f0.js":[7840,9632,4,1609702268191,2,null,null,"../../../utils.ts",0,35],"4a214f036c2197a3.js":[9632,18832,17,1609702305847,2,null,null,"../../../index.js",0,472],"8bd6d8bafed72c02.js":[18832,20912,4,1609702292217,2,null,null,"../../../config.ts",0,35],"4ea918b634e7ddee.js":[20912,79016],"cfe8e44034e7ddee.js":[79016,82488],"b4a6e37534e7ddee.js":[82488,83856],"1e05fd5334e7ddee.js":[83856,85064],"bf10b4f234e7ddee.js":[85064,86400],"8f40bea234e7ddee.js":[86400,87512],"7e09912634e7ddee.js":[87512,88504],"2674ff5934e7ddee.js":[88504,89592],"8998963e34e7ddee.js":[89592,91136],"502bd04b34e7ddee.js":[91136,92256],"66c70c9d34e7ddee.js":[92256,93352],"8f1bb44f34e7ddee.js":[93352,94544],"434e4b9234e7ddee.js":[94544,95640],"cda6849f34e7ddee.js":[95640,96744],"e3420b7d34e7ddee.js":[96744,97648],"8b712e7434e7ddee.js":[97648,98768],"2053138034e7ddee.js":[98768,99896],"c582ecc634e7ddee.js":[99896,100672],"0bac123734e7ddee.js":[100672,103384],"1c7694f234e7ddee.js":[103384,105408],"5faa8dc034e7ddee.js":[105408,107848],"97c0385c34e7ddee.js":[107848,109936],"36df28f334e7ddee.js":[109936,112432],"eb69a67234e7ddee.js":[112432,114360],"5cfbe43834e7ddee.js":[114360,116592],"49f59e8a34e7ddee.js":[116592,127104],"d51c7bf134e7ddee.js":[127104,129496],"8a2f4c9c34e7ddee.js":[129496,131024],"10f0948334e7ddee.js":[131024,132976],"05b6411534e7ddee.js":[132976,149592],"e63a0d4134e7ddee.js":[149592,151264],"665d971034e7ddee.js":[151264,157112],"506d4c4234e7ddee.js":[157112,158936],"bc5923d134e7ddee.js":[158936,164960],"06f7b82c34e7ddee.js":[164960,166944],"c8b25ccd34e7ddee.js":[166944,172904],"1f5433a534e7ddee.js":[172904,174784],"e5bd35c434e7ddee.js":[174784,178496],"8e4a9ef134e7ddee.js":[178496,180376],"82c6418834e7ddee.js":[180376,182840],"0f45284634e7ddee.js":[182840,185816],"a46ec2ab34e7ddee.js":[185816,187880],"581626d034e7ddee.js":[187880,192080],"91804a3134e7ddee.js":[192080,194152],"6ab8978a34e7ddee.js":[194152,203800],"f875f50734e7ddee.js":[203800,208160],"93569bf434e7ddee.js":[208160,210208],"e76687d634e7ddee.js":[210208,213264],"112ad7a934e7ddee.js":[213264,215568],"d7317d4034e7ddee.js":[215568,217624],"20cf856b34e7ddee.js":[217624,218808],"4b5cde3834e7ddee.js":[218808,229632],"3d32dce434e7ddee.js":[229632,234216],"54a236fc34e7ddee.js":[234216,237776],"0284fc9e1e0f713c.js":[237776,255568],"a8f15fcc34e7ddee.js":[255568,256704],"b0a2f5d334e7ddee.js":[256704,258456],"135aeb1534e7ddee.js":[258456,260976],"3aed101f34e7ddee.js":[260976,263320],"67a658bc34e7ddee.js":[263320,267520],"92b7bd0d34e7ddee.js":[267520,270280],"51a1bfca34e7ddee.js":[270280,271432],"8b76f93b34e7ddee.js":[271432,273432],"e5dbf4c734e7ddee.js":[273432,275008],"75cfb7f334e7ddee.js":[275008,280240],"3850b3a734e7ddee.js":[280240,282168],"b771994234e7ddee.js":[282168,284344],"8785e88234e7ddee.js":[284344,285920],"7ce9446134e7ddee.js":[285920,288984],"0551020634e7ddee.js":[288984,290800],"4cbe626c34e7ddee.js":[290800,291856],"bbae285f34e7ddee.js":[291856,293416],"920f6c777d217eb1.js":[293416,296328],"6f58dc5534e7ddee.js":[296328,297232],"0cc3bc0992c47e23.js":[297232,298064],"a474b7b434e7ddee.js":[298064,300208],"972b86bf4a371210.js":[300208,301072],"cd8930bc34e7ddee.js":[301072,303704],"0eafaf3234e7ddee.js":[303704,305240],"0caa99b934e7ddee.js":[305240,306320],"d29740ff34e7ddee.js":[306320,309800],"f693a2a834e7ddee.js":[309800,311320],"00f4096434e7ddee.js":[311320,313000],"66e222ca34e7ddee.js":[313000,321208],"b6f27b6b34e7ddee.js":[321208,322016],"4618d65334e7ddee.js":[322016,323848],"47ec677034e7ddee.js":[323848,325232],"a6a949ec34e7ddee.js":[325232,326368],"3a7392a334e7ddee.js":[326368,328880],"a5de0d2834e7ddee.js":[328880,329864],"b4cc734134e7ddee.js":[329864,337112],"d3dc197e6408243f.js":[337112,337928],"6457305334e7ddee.js":[337928,340112],"2681d3c834e7ddee.js":[340112,342384],"4527f91e34e7ddee.js":[342384,343544],"af5182ed34e7ddee.js":[343544,344920],"357b6f0e34e7ddee.js":[344920,346728],"89a48c1c34e7ddee.js":[346728,348000],"e0279dc834e7ddee.js":[348000,349752],"787a006e34e7ddee.js":[349752,350704],"ebf2880534e7ddee.js":[350704,353416],"c8e1dfdc34e7ddee.js":[353416,355064],"4390ae1534e7ddee.js":[355064,358664],"8d2da48134e7ddee.js":[358664,359872],"5f16e98b34e7ddee.js":[359872,364960],"4fbbd02934e7ddee.js":[364960,368968],"f0b51d8e34e7ddee.js":[368968,370816],"06b5860134e7ddee.js":[370816,374312],"52a3a93334e7ddee.js":[374312,376224],"d8594d5534e7ddee.js":[376224,379760],"4a214f03e9b6dca2.js":[379760,389072,17,1609702667126,2,null,null,"../../../index.js",0,472],"3ef83326954c7b1f.js":[389072,391776,4,1609702667122,2,null,null,"../../../utils.ts",0,35],"3ef83326a1534815.js":[391776,394560,4,1609702893482,2,null,null,"../../../utils.ts",0,35],"3ef8332650409682.js":[394560,397272,4,1609702929886,2,null,null,"../../../utils.ts",0,35]},"version":"3.2.25"}

@ -0,0 +1,18 @@
_504.x([["default",()=>_504.o]]);const moment = require("moment");
class utils {
convertRssDate(rssDate){
let converted = moment(rssDate).format('YYYY-MM-DD LTS') ;// in js format like 2021-03-12T19:00:00Z
console.log('converted', converted)
// like 2021-01-03 15:31:02.918940
return converted
}
testdateconvert(){
let converted = this.convertRssDate('2021-03-12T19:00:00Z')
console.log('converted', converted)
}
}
_504.d(utils);

@ -1,13 +0,0 @@
_c93.x([["default",()=>_c93.o]]);const moment = require("moment");
const utils = {
convertRssDate: (rssDate) => {
let converted = moment(rssDate).format('L');// in js format like 2021-03-12T19:00:00Z
console.log('converted', converted)
// like 2021-01-03 15:31:02.918940
return converted
}
}
_c93.d(utils);

@ -1,4 +1,4 @@
let utils,parserConfig,uuidv4,htmlEscape,Parser,Client;_6c2.w("./utils.ts",[["default",["utils"],function(v){utils=v}]]);_6c2.w("./config.ts",[["default",["parserConfig"],function(v){parserConfig=v}]]);_6c2.w("uuid",[["v4",["uuidv4"],function(v){uuidv4=v}]]);_6c2.w("escape-goat",[["htmlEscape",["htmlEscape"],function(v){htmlEscape=v}]]);_6c2.w("rss-parser",[["default",["Parser"],function(v){Parser=v}]]);_6c2.w("pg",[["Client",["Client"],function(v){Client=v}]]);// @author tykayn contact@cipherbliss.com www.cipherbliss.com
let utils,parserConfig,uuidv4,htmlEscape,Parser,Client;_e9b.w("./utils.ts",[["default",["utils"],function(v){utils=v}]]);_e9b.w("./config.ts",[["default",["parserConfig"],function(v){parserConfig=v}]]);_e9b.w("uuid",[["v4",["uuidv4"],function(v){uuidv4=v}]]);_e9b.w("escape-goat",[["htmlEscape",["htmlEscape"],function(v){htmlEscape=v}]]);_e9b.w("rss-parser",[["default",["Parser"],function(v){Parser=v}]]);_e9b.w("pg",[["Client",["Client"],function(v){Client=v}]]);// @author tykayn contact@cipherbliss.com www.cipherbliss.com
// imports
@ -15,18 +15,22 @@ let utils,parserConfig,uuidv4,htmlEscape,Parser,Client;_6c2.w("./utils.ts",[[
let parser = new Parser();
// @ts-ignore
_6c2.g.console.log(' ==============================================='.blue);
_e9b.g.console.log(' ==============================================='.blue);
// @ts-ignore
_6c2.g.console.log(' ==== Rss Feeder for mobilizon - by tykayn ===='.blue);
_e9b.g.console.log(' ==== Rss Feeder for mobilizon - by tykayn ===='.blue);
// @ts-ignore
_6c2.g.console.log(' ==============================================='.blue);
_e9b.g.console.log(' ==============================================='.blue);
if (parserConfig.debug) {
// @ts-ignore
_6c2.g.console.log('configMobilizon'.blue, config);
_e9b.g.console.log('configMobilizon'.blue, config);
}
const utilsTools = new utils();
let localMobilizonEventsByTitle = [];
utilsTools.testdateconvert();
// trouver si un évènement existe déjà par son titre
// TODO à affiner au delà du titre
const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
@ -35,7 +39,7 @@ const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
if (!eventAlreadyExists) {
if (parserConfig.debug) {
_6c2.g.console.log('ajouter l event ', htmlEscape(rssEvent.title));
_e9b.g.console.log('ajouter l event ', htmlEscape(rssEvent.title));
}
addEventQuery(rssEvent);
}
@ -58,7 +62,7 @@ const addEventQuery = (rssEvent) => {
let uuidString = '\'' + uuid + '\'';
let eventUrl = '\'' + parserConfig.mobilizon_public_url + '/events/' + uuid + '\'';
let begins_on = '\'' + uuid + '\'';
let ends_on = '\'' + utils.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 =
@ -78,10 +82,10 @@ const runCreationQuery = async () => {
console.log(' ⚙ ');
console.log(' ');
console.log(' createEventQueries');
_6c2.g.console.log(createEventQueries);
_e9b.g.console.log(createEventQueries);
const res = await client.query(createEventQueries);
_6c2.g.console.log('res', res);
_e9b.g.console.log('res', res);
return res;
}
};
@ -100,33 +104,33 @@ const client = new Client({
console.log('✅ OK connecté à postgresql');
console.log(' ');
const res = await client.query('SELECT * from events');
_6c2.g.console.log('💾 évènements enregistrés dans mobilizon : ', res.rows.length); // Hello world!
_e9b.g.console.log('💾 évènements enregistrés dans mobilizon : ', res.rows.length); // Hello world!
res.rows.forEach((item) => {
localMobilizonEventsByTitle.push(item.title);
_6c2.g.console.log(' 🟢 ', item.begins_on, item.ends_on, item.title, item.url);
_e9b.g.console.log(' 🟢 ', item.begins_on, item.ends_on, item.title, item.url);
});
if (parserConfig.askAgendaDuLibre) {
// @ts-ignore
_6c2.g.console.log(' ===================================================='.blue);
_e9b.g.console.log(' ===================================================='.blue);
// @ts-ignore
_6c2.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
_e9b.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
// @ts-ignore
_6c2.g.console.log(' ===================================================='.blue);
_e9b.g.console.log(' ===================================================='.blue);
_6c2.g.console.log('⌛ lecture du flux rss : ' + parserConfig.rss_feed_url);
_e9b.g.console.log('⌛ lecture du flux rss : ' + parserConfig.rss_feed_url);
let feed = await parser.parseURL(parserConfig.rss_feed_url);
console.log('✅ flux rss obtenu');
_6c2.g.console.log(feed.title);
_e9b.g.console.log(feed.title);
console.log('⚙ interprétation des évènements');
console.log(
'⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql',
);
feed.items.forEach((rssEvent) => {
_6c2.g.console.log(rssEvent.title);
_e9b.g.console.log(rssEvent.title);
// console.log('item', item)
doesThisEventAlreadyExistInLocalEvents(rssEvent);
});
@ -134,32 +138,32 @@ const client = new Client({
}
if (parserConfig.askOsmCal) {
// @ts-ignore
_6c2.g.console.log(' ===================================================='.blue);
_e9b.g.console.log(' ===================================================='.blue);
// @ts-ignore
_6c2.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
_e9b.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
// @ts-ignore
_6c2.g.console.log(' ===================================================='.blue);
_e9b.g.console.log(' ===================================================='.blue);
}
if (parserConfig.runAddQueriesToMobilizon) {
// @ts-ignore
_6c2.g.console.log('➕ rajouter les évènements manquants à la base mobilizon'.blue);
_e9b.g.console.log('➕ rajouter les évènements manquants à la base mobilizon'.blue);
await runCreationQuery();
// @ts-ignore
_6c2.g.console.log(' ---------- '.green);
_e9b.g.console.log(' ---------- '.green);
// @ts-ignore
_6c2.g.console.log(counterOfEventsToAdd, ' évènements ajoutés '.green);
_e9b.g.console.log(counterOfEventsToAdd, ' évènements ajoutés '.green);
// @ts-ignore
_6c2.g.console.log(' ---------- '.green);
_e9b.g.console.log(' ---------- '.green);
// @ts-ignore
_6c2.g.console.log('✅ ça c\'est fait '.green);
_e9b.g.console.log('✅ ça c\'est fait '.green);
}
await client.end();
})();
exports = () => {
_6c2.g.console.log('hey ho', this);
_e9b.g.console.log('hey ho', this);
};

@ -1,13 +1,18 @@
const moment = require("moment");
const utils = {
class utils {
convertRssDate: (rssDate) => {
let converted = moment(rssDate).format('L');// in js format like 2021-03-12T19:00:00Z
convertRssDate(rssDate){
let converted = moment(rssDate).format('YYYY-MM-DD LTS') ;// in js format like 2021-03-12T19:00:00Z
console.log('converted', converted)
// like 2021-01-03 15:31:02.918940
return converted
}
testdateconvert(){
let converted = this.convertRssDate('2021-03-12T19:00:00Z')
console.log('converted', converted)
}
}
export default utils;

Loading…
Cancel
Save