Browse Source

give a better name to merge function

fix-broken-scrape
Jørgen Lien Sellæg 6 years ago
parent
commit
9137a01158
  1. 11
      src/logic.js
  2. 11
      src/scrape.js

11
src/logic.js

@ -1,4 +1,4 @@
const { hasPath, pathOr, props } = require('ramda');
const { hasPath, pathOr, props, uniqBy, eqBy, prop, union } = require('ramda');
const parseArgs = require('minimist');
const process = require('process');
@ -139,14 +139,17 @@ const has_upcoming_events = (body) =>
const has_past_events = (body) =>
body.includes('past events') && !body.includes('not have any past events');
const merge_events = (a, b) => uniqBy(eqBy(prop('event_id')))(union(a, b));
module.exports = {
has_past_events,
get_body_inner_text,
has_upcoming_events,
get_upcoming_events_from_page,
get_past_events_from_page,
get_upcoming_events_from_page,
has_past_events,
has_upcoming_events,
map_event,
merge_edges,
merge_events,
parse_args,
read_previous_events,
};

11
src/scrape.js

@ -1,5 +1,10 @@
const { pathOr, uniqBy, eqBy, prop, union } = require('ramda');
const { merge_edges, parse_args, read_previous_events } = require('./logic');
const { pathOr } = require('ramda');
const {
merge_edges,
parse_args,
read_previous_events,
merge_events,
} = require('./logic');
const { open_browser, get_page_events } = require('./browser');
const {
@ -23,7 +28,7 @@ const {
get_upcoming_events,
get_past_events,
);
events = uniqBy(eqBy(prop('event_id')))(union(events, page_events));
events = merge_events(events, page_events);
}
} catch (e) {
console.error(e);

Loading…
Cancel
Save