z_pivot_rsc (zotonic_core v1.0.0-rc.14)

Pivoting server for the rsc table. Takes care of full text indices. Polls the pivot queue for any changed resources.

Link to this section Summary

Functions

Convert process state when code is changed
Let a module define a custom pivot columns() -> [column()] column() -> {ColumName::atom(), ColSpec::string()} | {atom(), string(), options::list()}
Handling all non call/cast messages
Initiates the server.
Insert a rsc_id in the pivot queue
Insert a rsc_id in the pivot queue for a certain date
Insert a slow running pivot task. For example syncing category numbers after an category update.
Insert a slow running pivot task. Use the UniqueKey to prevent double queued tasks.
Insert a slow running pivot task with unique key and arguments.
Insert a slow running pivot task with unique key and arguments that should start after Seconds seconds. Always delete any existing transaction, to prevent race conditions when the task is running during this insert. The UniqueKey is used to have multiple entries per module/function. If only a single module/function should be queued, then set the UniqueKey to <<>>.
Lookup a custom pivot; give back the Id based on a column. Will always return the first Id found.
An immediate pivot request for a resource
Delay the next pivot, useful when performing big updates
Signal from pivot job that processing is done.
Ping from pivot process to keep alive and report progress
Return a modified property list with fields that need immediate pivoting on an update.
Poll the pivot queue for the database in the context
Rebuild the search index by queueing all resources for pivot.
Return the length of the pivot queue.
Starts the server
Return the language used for stemming the full text index. We use a single stemming to prevent having seperate indexes per language.
Signal from task process that job is finished.
Ping from task process to keep alive and report progress
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Link to this section Functions

Link to this function

cleanup_tsv_text(Text)

-spec cleanup_tsv_text(binary()) -> binary().
Link to this function

code_change(OldVsn, State, Extra)

Convert process state when code is changed
Link to this function

count_tasks(Context)

-spec count_tasks(z:context()) -> {ok, [map()]} | {error, term()}.
Link to this function

define_custom_pivot(Module, Columns, Context)

Let a module define a custom pivot columns() -> [column()] column() -> {ColumName::atom(), ColSpec::string()} | {atom(), string(), options::list()}
Link to this function

delete_task(Module, Function, Context)

-spec delete_task(module(), atom(), z:context()) -> non_neg_integer().
Link to this function

delete_task(Module, Function, UniqueKey, Context)

-spec delete_task(module(), atom(), term(), z:context()) -> non_neg_integer().
Link to this function

delete_tasks(Context)

-spec delete_tasks(z:context()) -> non_neg_integer().
Link to this function

get_pivot_title(Props)

-spec get_pivot_title(map()) -> binary().
Link to this function

get_pivot_title(Id, Context)

-spec get_pivot_title(m_rsc:resource_id(), z:context()) -> binary().
Link to this function

get_task(Context)

-spec get_task(z:context()) -> {ok, [map()]} | {error, term()}.
Link to this function

get_task(Module, Context)

-spec get_task(module(), z:context()) -> {ok, [map()]} | {error, term()}.
Link to this function

get_task(Module, Function, Context)

-spec get_task(module(), atom(), z:context()) -> {ok, [map()]} | {error, term()}.
Link to this function

get_task(Module, Function, UniqueKey, Context)

-spec get_task(module(), atom(), binary() | string(), z:context()) -> {ok, map()} | {error, term()}.
Link to this function

handle_call(Message, From, State)

Link to this function

handle_cast(Message, State)

Link to this function

handle_info(Info, State)

Handling all non call/cast messages
Initiates the server.
Link to this function

insert_queue(IdorIds, Context)

-spec insert_queue(m_rsc:resource_id() | [m_rsc:resource_id()], z:context()) -> ok | {error, eexist}.
Insert a rsc_id in the pivot queue
Link to this function

insert_queue(Id, DueDate, Context)

-spec insert_queue(m_rsc:resource_id() | [m_rsc:resource_id()], calendar:datetime(), z:context()) ->
                ok | {error, eexist}.
Insert a rsc_id in the pivot queue for a certain date
Link to this function

insert_task(Module, Function, Context)

-spec insert_task(Module, Function, Context) -> {ok, TaskId} | {error, term()}
               when
                   Module :: atom(),
                   Function :: atom(),
                   Context :: z:context(),
                   TaskId :: integer().
Insert a slow running pivot task. For example syncing category numbers after an category update.
Link to this function

insert_task(Module, Function, UniqueKey, Context)

-spec insert_task(Module, Function, UniqueKey, Context) -> {ok, TaskId} | {error, term()}
               when
                   Module :: atom(),
                   Function :: atom(),
                   UniqueKey :: undefined | binary() | string() | atom(),
                   Context :: z:context(),
                   TaskId :: integer().
Insert a slow running pivot task. Use the UniqueKey to prevent double queued tasks.
Link to this function

insert_task(Module, Function, UniqueKey, Args, Context)

-spec insert_task(Module, Function, UniqueKey, Args, Context) -> {ok, TaskId} | {error, term()}
               when
                   Module :: atom(),
                   Function :: atom(),
                   UniqueKey :: undefined | binary() | string() | atom(),
                   Args ::
                       list() |
                       fun((OldDue :: undefined | calendar:datetime(),
                            OldArgs :: undefined | list(),
                            NewDue :: calendar:datetime(),
                            z:context()) ->
                               {ok, {calendar:datetime(), list()}} | {error, term()}),
                   Context :: z:context(),
                   TaskId :: integer().
Insert a slow running pivot task with unique key and arguments.
Link to this function

insert_task_after(SecondsOrDate, Module, Function, UniqueKey, Args, Context)

-spec insert_task_after(SecondsOrDate, Module, Function, UniqueKey, Args, Context) ->
                     {ok, TaskId} | {error, term()}
                     when
                         SecondsOrDate :: undefined | integer() | calendar:datetime(),
                         Module :: atom(),
                         Function :: atom(),
                         UniqueKey :: undefined | binary() | string() | atom(),
                         Args ::
                             list() |
                             fun((OldDue :: undefined | calendar:datetime(),
                                  OldArgs :: undefined | list(),
                                  NewDue :: calendar:datetime(),
                                  z:context()) ->
                                     {ok, {calendar:datetime(), list()}} | {error, term()}),
                         Context :: z:context(),
                         TaskId :: integer().
Insert a slow running pivot task with unique key and arguments that should start after Seconds seconds. Always delete any existing transaction, to prevent race conditions when the task is running during this insert. The UniqueKey is used to have multiple entries per module/function. If only a single module/function should be queued, then set the UniqueKey to <<>>.
Link to this function

list_tasks(Context)

-spec list_tasks(z:context()) -> {ok, [map()]} | {error, term()}.
Link to this function

lookup_custom_pivot(Module, Column, Value, Context)

Lookup a custom pivot; give back the Id based on a column. Will always return the first Id found.
Link to this function

pg_lang(LangCode)

-spec pg_lang(atom()) -> string().
Link to this function

pg_lang_extra(LangCode)

-spec pg_lang_extra(atom()) -> string().
Link to this function

pivot(Id, Context)

-spec pivot(integer(), z:context()) -> ok.
An immediate pivot request for a resource
Link to this function

pivot_delay(Context)

-spec pivot_delay(z:context()) -> ok.
Delay the next pivot, useful when performing big updates
Link to this function

pivot_job_done(Context)

-spec pivot_job_done(z:context()) -> ok.
Signal from pivot job that processing is done.
Link to this function

pivot_job_ping(Id, Context)

-spec pivot_job_ping(m_rsc:resource_id(), z:context()) -> ok.
Ping from pivot process to keep alive and report progress
Link to this function

pivot_resource_update(Id, UpdateProps, RawProps, Context)

Return a modified property list with fields that need immediate pivoting on an update.
-spec poll(z:context()) -> ok.
Poll the pivot queue for the database in the context
Link to this function

queue_all(Context)

Rebuild the search index by queueing all resources for pivot.
Link to this function

queue_count(Context)

-spec queue_count(z:context()) -> integer().
Return the length of the pivot queue.
Link to this function

start_link(Site)

Starts the server
Link to this function

status(Context)

-spec status(z:context()) -> {ok, map()} | {error, term()}.
Link to this function

stemmer_language(Context)

-spec stemmer_language(z:context()) -> string().
Return the language used for stemming the full text index. We use a single stemming to prevent having seperate indexes per language.
Link to this function

stemmer_language_config(Context)

-spec stemmer_language_config(z:context()) -> atom().
Link to this function

task_job_done(TaskId, Context)

-spec task_job_done(TaskId :: integer(), z:context()) -> ok.
Signal from task process that job is finished.
Link to this function

task_job_ping(TaskId, Percentage, Context)

-spec task_job_ping(TaskId :: integer(), Percentage :: 0..100, z:context()) -> ok.
Ping from task process to keep alive and report progress
Link to this function

terminate(Reason, State)

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.