Tutorial for advanced query displaying current habit streaks

Hi,
I wanted to track my habits in logseq without a plugin but purely with advanced queries. Tracking the current length of habit streaks was most important to me. Therefore, I created a rather complicated advanced query. I had trouble finding tutorials on advanced queries that explain more advanced topics like

  • collections and relations as input
  • custom rules as input
  • recursively defined rules
  • creating tables for non-block like output with :view
  • counting based on conditions similar to this stackoverflow answer

Given the lack of such tutorials, I wrote up a small tutorial myself explaining my advanced query for habit streaks. I hope this helps some people. Furthermore, I am happy to receive some feedback.

Best,
Niklas