Implementated upsert for remaining_time.