So, i have an MongoDB aggregation that aggregates data from DB by weeks. According to documentation of $week aggregation:
Returns the week of the year for a date as a number between 0 and 53.
Weeks begin on Sundays, and week 1 begins with the first Sunday of the year. Days preceding the first Sunday of the year are in week 0.
I need to connect data from this week 0 to week 52 of previous year.
P.S. it is unknown in script wheter week 0 exists and will it be used or not
I used a "crutch" which parses data array and then migrates data from week 0 (it if exists) to week 52 by itself. But it can lead to bugs when working with arifmetical figures, for example: average, min, max. And this will lead to a lot of coding and refactoring. So, is it possible to unite data from week 0 to week 52 without crutches ?