Consecutive Days script help

Hi everyone,

I can’t wrap my head around this, I read the available doc but could not find anything that can pick up the right data…

I’d like a custom activity field that says: “this is the X consecutive day of training”, where X is the mumber of consecutive days of training till today. Let’s call it “ConsDays”, let’s consider bike ONLY.

Apparently the script for this custom activity field is easy:

If yesterday has 1 (or more) activity, ConsDays(today’s activity) = ConsDays(yesterday’s activity) + 1
If yesterday has no activity, ConsDays(today’s activity) = 1

Simple? Or not?

Thank you!

Riccardo