Farmevent cleanup

This commit is contained in:
Connor Rigby 2017-12-23 17:59:17 -08:00 committed by Connor Rigby
parent 51b32af1b9
commit bba016f3c0
2 changed files with 1 additions and 5 deletions

View file

@ -1,6 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <erl_nif.h>
@ -25,8 +23,6 @@ static ERL_NIF_TERM do_build_calendar(ErlNifEnv* env, int argc, const ERL_NIF_TE
gracePeriodSeconds = nowSeconds - 60;
long int step = frequencySeconds * repeat;
// printf("now: %li\r\ngrace: %li\r\nstart: %li\r\nend: %li\r\n\r\n", nowSeconds, gracePeriodSeconds, startTimeSeconds, endTimeSeconds);
// iterators for loops
long int i, j;

View file

@ -88,7 +88,7 @@ defmodule Farmbot.Repo.FarmEvent do
# This should be replaced. YOU WILL KNOW if not.
def do_build_calendar(now_seconds, start_time_seconds, end_time_seconds, repeat, repeat_frequency_seconds) do
Logger.error 1, "Using (very) slow calendar builder!"
grace_period_cutoff_seconds = now_seconds - 1
grace_period_cutoff_seconds = now_seconds - 60
Range.new(start_time_seconds, end_time_seconds)
|> Enum.take_every(repeat * repeat_frequency_seconds)
|> Enum.filter(&Kernel.>(&1, grace_period_cutoff_seconds))