tomykaira/clockwork — pull request #93 by robisenberg (2014-04-13 19:00:39+00:00)
Title: Refactor database-synced tasks to not delete/recreate tasks each sync

## Motivation

@Andyvanee raised an issue he was having with database synced tasks in the comments here: https://github.com/tomykaira/clockwork/pull/88.

> I'm trying to make use of this in my app and having some issues. I'm running tasks by setting the frequency but not the at. This works OK if the frequency is less than the update frequency for the manager, but not if it's greater. For example: if the manager updates every minute, but the task specifies 5 minutes, the task will still run every minute.
>
> I don't see any way around this other than not recreating the tasks out on every update. Any ideas?

This change fixes his bug.

## Changes

* change the way database-synced tasks work so we no longer delete and
recreate them on every database sync, but instead, we add only new
events, edit any that have changed, and remove events for database
tasks that have been deleted

* part of the above change involved creating a
DatabaseEventSyncPerformer to handle the details of performing the
actual sync of events from the database.

* updated tests which relied on previous assumption/implementation
that database tasks were synced on the minute boundary (i.e. MM:00
seconds). Now that's no longer the case, so switched tests that
started ticking at @next_minute, to start @now.

* Update README section "Use with database tasks" to remove bit
about running database sync on minute boundaries, and not running
database events in same cycle as sync since these are no longer
the case