Skip to content

Instantly share code, notes, and snippets.

@Zkuns
Last active November 17, 2017 03:27
Show Gist options
  • Save Zkuns/17089b12f6cd26d464c8c77c06407bdb to your computer and use it in GitHub Desktop.
Save Zkuns/17089b12f6cd26d464c8c77c06407bdb to your computer and use it in GitHub Desktop.
record_menses_times = app_user.app_menses_timelines.count
if record_menses_times > 1
relation = app_user.app_menses_timelines.order(start_date: :desc)
relation.each_with_index do |app_menses_timeline, menses_index|
if app_menses_timeline.interval.to_i < 2
app_user.update(is_valid: false)
break
end
menses_interval = nil
if (relation.length-menses_index) != 1
menses_interval = ( app_menses_timeline.start_date - relation[menses_index+1].start_date ).to_i
if (menses_interval <= 7) || (menses_interval >= 60)
app_user.update(is_valid: false)
break
end
end
end
else
app_user.update(is_valid: false)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment