Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opening-hours
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
regionalkauf
opening-hours
Commits
0d5b1354
Commit
0d5b1354
authored
Nov 12, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when timespan was from 0:00 to 0:00, overlap merge caused problem
parent
064ffc94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
+25
-12
timeUtils.js
lib/timeUtils.js
+1
-1
mapping.json
mapping.json
+12
-6
dataBaseQuery.js
serverTest/dataBaseQuery.js
+12
-5
No files found.
lib/timeUtils.js
View file @
0d5b1354
...
...
@@ -218,7 +218,7 @@ function mergeOverlaps(interval) {
var
endFirst
=
interval
[
i
][
1
];
var
startSecond
=
interval
[
i
+
1
][
0
];
var
endSecond
=
interval
[
i
+
1
][
1
];
if
(
endFirst
.
getTime
()
>
=
startSecond
.
getTime
())
{
if
(
endFirst
.
getTime
()
>
startSecond
.
getTime
())
{
interval
.
splice
(
i
+
1
,
1
);
interval
[
i
][
1
]
=
new
Date
(
Math
.
max
(
endFirst
,
endSecond
));
}
...
...
mapping.json
View file @
0d5b1354
...
...
@@ -2,31 +2,37 @@
"pos"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"2b41366d-7901-45e5-8d07-feaf42c4db46"
,
"oHoursExcl"
:
"8298b63a-ed54-468f-8398-2eac1a140213"
"oHoursExcl"
:
"8298b63a-ed54-468f-8398-2eac1a140213"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
},
"branch"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"a091bcd7-8b6d-4702-b43d-26c7b53adbac"
,
"oHoursExcl"
:
"96d0d7b9-bd17-4c2c-81af-185daf1b85c3"
"oHoursExcl"
:
"96d0d7b9-bd17-4c2c-81af-185daf1b85c3"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
},
"company"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"810a6deb-46f2-4fa8-b779-bb5c2a6b5577"
,
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
},
"catering"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"810a6deb-46f2-4fa8-b779-bb5c2a6b5577"
,
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
},
"community"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"810a6deb-46f2-4fa8-b779-bb5c2a6b5577"
,
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
},
"organisation"
:
{
"C_ZIP"
:
"ea0666d7-51e3-4e52-8617-25e3ad61f8b8"
,
"oHoursIncl"
:
"810a6deb-46f2-4fa8-b779-bb5c2a6b5577"
,
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
"oHoursExcl"
:
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
,
"oHoursMaybe"
:
"e85aacb0-bd79-4091-a271-85de0cebf66d"
}
}
\ No newline at end of file
serverTest/dataBaseQuery.js
View file @
0d5b1354
var
mysql
=
require
(
'mysql'
);
var
dateArray
=
require
(
'../lib/dateArray'
);
var
dateView
=
require
(
'../lib/dateView'
);
var
plz
=
93161
;
var
mapping
=
require
(
'../mapping.json'
);
var
util
=
require
(
'util'
);
var
connection
=
mysql
.
createConnection
({
host
:
'localhost'
,
...
...
@@ -19,7 +20,7 @@ module.exports.getData = function (now, cb) {
// dateArray.setEpocheSpan(epocheSpan);
// connection.query('SELECT name, elements FROM cms_zoo_item WHERE type in ("pos", "company") ORDER BY id', function (err, rows) {
connection
.
query
(
'SELECT name,
elements FROM cms_zoo_item WHERE id in (2927
)'
,
function
(
err
,
rows
)
{
connection
.
query
(
'SELECT name,
type, elements FROM cms_zoo_item WHERE id in (1871
)'
,
function
(
err
,
rows
)
{
console
.
error
(
err
);
console
.
log
(
rows
.
length
);
var
result
=
[];
...
...
@@ -27,15 +28,21 @@ module.exports.getData = function (now, cb) {
var
iters
=
rows
.
length
;
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
var
obj
=
JSON
.
parse
(
rows
[
i
].
elements
);
var
type
=
rows
[
i
].
type
;
var
typeM
=
mapping
[
type
];
var
hours
=
[
obj
[
typeM
[
'oHoursIncl'
]],
obj
[
typeM
[
'oHoursExcl'
]],
obj
[
typeM
[
'oHoursMaybe'
]]];
//console.log(util.inspect(hours, {depth: null}));
var
plz
=
obj
[
typeM
[
'C_ZIP'
]][
0
][
'value'
];
(
function
()
{
var
name
=
rows
[
i
].
name
;
var
idx
=
i
;
dateArray
(
epocheSpan
).
getData
(
obj
,
plz
,
function
(
err
,
dataObj
)
{
console
.
log
(
dataObj
);
dateArray
(
epocheSpan
).
getData
(
hours
,
plz
,
function
(
err
,
dataObj
)
{
//
console.log(dataObj);
if
(
err
)
{
console
.
log
(
name
,
err
);
}
else
if
(
dataObj
&&
(
dataObj
.
intervals
.
length
>
0
||
dataObj
.
maybeIntervals
.
length
>
0
))
{
if
(
dataObj
&&
(
dataObj
.
intervals
.
length
>
0
||
dataObj
.
maybeIntervals
.
length
>
0
))
{
cnt
++
;
var
view
=
dateView
.
getView
(
dataObj
,
now
);
var
asString
=
dateView
.
asString
(
dataObj
,
now
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment