anchor.diff:  
   %% @doc Poll a database for any queued updates.
   do_poll(Context) ->
  -	case poll_task(Context) of
  -		{Module, Function, Key, Args} -> 
  +    % Perform some queued tasks
  +    case poll_task(Context) of
  +        {Module, Function, Key, Args} -> 
               try 
                   erlang:apply(Module, Function, z_convert:to_list(Args) ++ [Context])
               catch
  
positive.code: 
  %% @doc Rebuild the search index by queueing all resources for pivot.
  queue_all(Context) ->
      z_db:q("UPDATE rsc SET version=version+1", Context).
  
  
  %% @doc Insert a slow running pivot task. For example syncing category numbers after an category update.
  insert_task(Module, Function, Context) ->
  	insert_task(Module, Function, z_ids:id(), [], Context).
  
  %% @doc Insert a slow running pivot task. Use the UniqueKey to prevent double queued tasks.
  insert_task(Module, Function, UniqueKey, Context) ->
  	insert_task(Module, Function, UniqueKey, [], Context).
  	
  %% @doc Insert a slow running pivot task with unique key and arguments.
  insert_task(Module, Function, UniqueKey, Args, Context) ->
  	z_db:transaction(fun(Ctx) -> insert_transaction(Module, Function, UniqueKey, Args, Ctx) end, Context).
  
  	insert_transaction(Module, Function, UniqueKey, Args, Context) ->
  		Fields = [
  			{module, Module},
  			{function, Function},
  			{key, UniqueKey},
  			{args, Args}
  		],
  		case z_db:q1("select id from pivot_task_queue where module = $1 and function = $2 and key = $3", 
  					[Module, Function, UniqueKey], Context) of
  			undefined -> z_db:insert(pivot_task_queue, Fields, Context);
  			Id -> {ok, Id}
  		end.
  
  
  
  
negative.code: 
  %% @doc Fetch the title of all things related to the resource
  related(Id, Context) ->
      Ids = lists:usort(m_edge:objects(Id, Context)),
      Ids1 = z_notifier:foldr({pivot_related, Id}, Ids, Context),
      IdsTexts = z_notifier:foldr({pivot_related_text_ids, Id}, Ids, Context),
      Texts = [ m_rsc:p(R, title, Context) || R <- IdsTexts ],
      {Ids1, Texts}.
      
  
  