E
E
Eugene2017-10-22 14:27:46
Regular Expressions
Eugene, 2017-10-22 14:27:46

In what form is it best to store an interval schedule in the database / Elasticsearch in order to make various kinds of selections?

Hello, the UI for adding a schedule looks something like this:
59ec7c24cbda1203495490.png
At the output, we have this json

[
 {
  "times": [
    {"start": "10:00", "end": "11:30"},
    {"start": "14:00", "end": "15:30"},
    {"start": "16:00", "end": "17:30"}
   ], 
   "dates": {
     "start": "21.10.2017",
     "end": "25.10.2017"
   }
]

I save it in jsonb postgresql field.
For the back, the task is to choose from the database:
1. Those sessions that will be today, given that:
1.1. There are sessions that start today (for example at 23:30) and end tomorrow (at 01:00)
1.2 There are sessions that start at 00:30 or even at 04:00 the next day, but I would like to show them as sessions on today
I'm interested in the opinion of how architecturally you would solve a similar problem?
Would you use elasticsearch or just postgresql? And if only postgre, then would you store the prepared data in a separate table or would you search by jsonb field?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dollar, 2019-07-23
@dollar

If you remove the characters from the beginning and end of the line, then everything works

Obviously, there is something at the beginning or at the end. For example, a newline character. Well, or there is still an option that the entire text is glued into a string or something like that (hardly).
To check, try to tritely understand what is there:
^(.*)total processes:[ \t]+[0-9]+

K
kn0ckn0ck, 2017-10-22
@kn0ckn0ck

It used to be scolded for the fact that languages ​​\u200b\u200band libraries are wasteful of memory - they don’t save it. Now they are scolded for being wasteful with services / technologies - slap sql, slap nosql and you're done.
The task described is not architecturally significant, it is a matter of designing your code. Why not store the date/time in a linear format, like UNIX_TIMESTAMP for example? In this space, the described tasks are easily solved even on a regular calculator, not to mention elasticsearch...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question