Multiple data sources in the interface - client-side "SQL"

Sometimes, in the interface of our VLSI applications , it becomes  necessary to "group" some of the entries  in a certain list (for example, service messages in the chat, contacts and phone calls).





It's good if all these records come from one source, but if they come  from different services, and with cursor navigation  , the implementation algorithm becomes very non-trivial.





I will purposefully not give the implementation "in code" here, but I will describe an exclusively algorithmic approach to the solution, so that, if necessary, you can scale it yourself to your tasks. So...





Formulation of the problem

We have two services. There could be more, but following the previous picture, let, for the sake of clarity, be  Calls and Contacts services .





Thanks to colleagues from CRM for an interesting task. In the meantime, there is no need to know about it. ”





    ,  ""   .





  ""  - , - , .





Grouping multiple calls into one entry

, , , , :





  • PostgreSQL Antipatterns: JOIN





  • PostgreSQL Antipatterns:





  • SQL HowTo: while- , Β« Β»





#1: " "

,   -, - ,   . -   .





" " , . "",   ?





#2: " "

, ?..   (20 ) ,     "" , - .





, ( ) "" - ?   , .





,    ( ), .   , "".





#1: " "

, ,    - - ( 20), - .





   , - (merge ordered) (limit) "" .





, , "" 15 20 . 5 , " " -   .





#3: "One Ring to rule them all"

? ,    - , .     - , .





, " - , "   - , .





#4: " server-side"

-   , . , ,   .





 stateless server-side , , -  . , :





  •   ---





  •     , ""





  •   --





#2: " client-side"

, -,   ?.. .





 , " "   (, , localStorage), .





- :





  • 20 20





  • "" 5





  • 5 "" + 15





  • 5





  • 20 - ? ! ( 20, "" )





  • " ", 25 20





Edge Cases

, -  "" " ", "" .





,   , : ", , , , !"








All Articles