Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Last active May 2, 2019 04:08
Show Gist options
  • Save vladbatushkov/ad61882b62dd8a2a5ae9ff4d09199f2d to your computer and use it in GitHub Desktop.
Save vladbatushkov/ad61882b62dd8a2a5ae9ff4d09199f2d to your computer and use it in GitHub Desktop.
Generate a graph with nodes of working days and weekends.
WITH date({ year: 2019, month: 12, day: 31 }) as lastDay
UNWIND range(1, lastDay.ordinalDay) as iterator
WITH date(toString(lastDay.year) + CASE WHEN iterator <= 9 THEN "00" WHEN iterator > 9 AND iterator <= 99 THEN "0" ELSE "" END + toString(iterator)) as day
FOREACH(day IN CASE WHEN (day.dayOfWeek > 5) THEN [day] ELSE [] END |
CREATE (:Weekend { day: day, workingHours: 0 })
)
FOREACH(day IN CASE WHEN (day.dayOfWeek < 6) THEN [day] ELSE [] END |
CREATE (:WorkingDay { day: day, workingHours: 8 })
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment