Commit a1e2dfd9 authored by Johannes Bill's avatar Johannes Bill

modifications for hallo-nachbarn

parent fbfec87c
"use strict";
var Promise = require('bluebird');
var dateArray = require('./lib/dateArray');
var dateView = require('./lib/dateView');
var splitMidnight = require('./lib/timeUtils').splitMidnight;
function mapEvents(intervals) {
if (intervals) {
return splitMidnight(intervals).map(function(evt) {
// var splitIntervals = splitMidnight(intervals);
var splitIntervals = intervals;
return splitIntervals.map(function(evt) {
return {
startDate: evt[0],
endDate: evt[1]
......@@ -26,6 +28,7 @@ function transform(x) {
return res;
}
// intervals for elasticsearch index (to allow opening hours filters)
function getOHIndex(info, today, cb) {
today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
......@@ -59,7 +62,7 @@ function mapCustomIntervals(customIvals) {
return res;
}
// for detail view, events* contain intervals {from, to}
function getFull(info, now, cb) {
var epocheSpan = dateView.getPropperEpochSpan(now);
dateArray(epocheSpan).getData(info, function (err, dataObj) {
......@@ -70,7 +73,7 @@ function getFull(info, now, cb) {
isOpen: short.isOpen,
text: short.text,
status: short.status,
weekView: dateView.weekViewData(dataObj, now),
// weekView: dateView.weekViewData(dataObj, now),
events: mapEvents(dataObj.intervals),
eventsMaybe: mapEvents(dataObj.maybeIntervals),
customEvents: mapCustomIntervals(dataObj.customIntervals)
......@@ -80,6 +83,7 @@ function getFull(info, now, cb) {
})
}
// for list view
function getShort(info, now, cb) {
var epocheSpan = dateView.getPropperEpochSpan(now);
dateArray(epocheSpan).getData(info, function (err, dataObj) {
......@@ -89,10 +93,12 @@ function getShort(info, now, cb) {
})
}
// info is {state: "Bayern", zip: 1234, religiousHoliday: true, data: {include, exclude, maybe}}
module.exports = {
getOHIndex: getOHIndex,
getFull: getFull,
getShort: getShort,
pretify: require('./lib/pretifyData').pretify
getOHIndex: Promise.promisify(getOHIndex),
getFull: Promise.promisify(getFull),
getShort: Promise.promisify(getShort)
};
......@@ -4,6 +4,7 @@
"main": "index.js",
"dependencies": {
"async": "^2.0.1",
"bluebird": "^3.4.6",
"moment": "^2.15.0"
},
"devDependencies": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment