B:BD[
10.6123] → [
10.6123:6728]
B:BD[
10.6728] → [
12.6617:6705]
∅:D[
12.6705] → [
10.6810:7167]
B:BD[
10.6810] → [
10.6810:7167]
B:BD[
10.7167] → [
12.6706:6756]
∅:D[
12.6756] → [
10.7214:7264]
B:BD[
10.7214] → [
10.7214:7264]
if(Array.isArray(parameters.times) && parameters.times.length) {
let times = parameters.times.map((time, idx) => {
let ts = time.time_start.split(':');
ts = Number(time.day_start) * 1440 + Number(ts[0]) * 60 + Number(ts[1]);
let te = time.time_end.split(':');
te = Number(time.day_end) * 1440 + Number(te[0]) * 60 + Number(te[1]);
if(te <= ts) {//
return `time ${idx}: close time(${days_of_week[time.day_end]} ${time.time_end}) must be later than open time(${days_of_week[time.day_start]} ${time.time_start})`;//
}//
return `((select store_id from insert1), $${params.push(`[${ts}, ${te})`)})`;
});
let time_errors = times.filter(time => time.startsWith('time'));//
if(time_errors.length) {//
ws.send(JSON.stringify({//
response_ID: request_ID,//
data: time_errors//
}));//
break;//
}//to overcome postgres error shortcoming
query += `, insert${++q} as (
insert into store_time (store_id, open)
values ${times.join(', ')}
)`;
if(Array.isArray(parameters.times)) {
let fuck = [];
for(let i = 0; i < parameters.times.length; ++i) {
try {
let ts = parameters.times[i].time_start.split(':');
ts = Number(parameters.times[i].day_start) * 1440 + Number(ts[0]) * 60 + Number(ts[1]);
let te = parameters.times[i].time_end.split(':');
te = Number(parameters.times[i].day_end) * 1440 + Number(te[0]) * 60 + Number(te[1]);
if(te <= ts) {
fuck.push(`(int4range($${params.push(ts)}, 10080)),(int4range(0, $${params.push(te)}))`);
//oops possibly 0,0 empty range. nvm good job range_agg
} else {
fuck.push(`(int4range($${params.push(ts)}, $${params.push(te)}))`);
}
} catch(e) {}
}
if(fuck.length) {
query += `, insert${++q} as (
insert into store_time (store_id, open)
select store_id, unnest from insert1 cross join (select unnest(range_agg(column1, true, true)) from (values ${fuck.join(',')}) as ex) as idc
)`;
}