l.b.m.bugtasksearch : module documentation

Part of lp.bugs.model

No module docstring
Function search_value_to_storm_where_condition Convert a search value to a Storm WHERE condition.
Function search_bugs Return a ResultSet of BugTasks for the given search parameters.
Function get_bug_privacy_filter An SQL filter for search results that adds privacy-awareness.
Function get_bug_privacy_filter_terms Return Storm terms for filtering bugs by visibility.
Function get_bug_bulk_privacy_filter_terms Return Storm terms for filtering people by bug visibility.
Function _build_origin Build the parameter list for Store.using().
Function _build_query Build and return an SQL query with the given parameters.
Function _process_order_by Process the orderby parameter supplied to search().
Function _require_params Undocumented
Function _build_search_text_clause Build the clause for searchtext.
Function _build_status_clause Return the SQL query fragment for search by status.
Function _build_exclude_conjoined_clause Exclude bugtasks with a conjoined master.
Function _build_hardware_related_clause Hardware related SQL expressions and tables for bugtask searches.
Function _build_blueprint_related_clause Find bugs related to Blueprints, or not.
Function _build_pending_bugwatch_elsewhere_clause Return a clause for BugTaskSearchParams.pending_bugwatch_elsewhere
Function _build_no_upstream_bugtask_clause Return a clause for BugTaskSearchParams.has_no_upstream_bugtask.
Function _build_open_or_resolved_upstream_clause Return a clause for BugTaskSearchParams.open_upstream or
Function _build_open_upstream_clause Return a clause for BugTaskSearchParams.open_upstream.
Function _build_resolved_upstream_clause Return a clause for BugTaskSearchParams.open_upstream.
Function _build_upstream_clause Return an clause for returning upstream data if the data exists.
Function _build_tag_set_query Undocumented
Function _build_tag_set_query_all Return a Storm expression for bugs matching all given tags.
Function _build_tag_set_query_any Return a Storm expression for bugs matching any given tag.
Function _build_tag_search_clause Return a tag search clause.
Function _nocache_bug_decorator A pass through decorator for consistency.
Function _make_cache_user_can_view_bug Curry a decorator for bugtask queries to cache permissions.
Function _get_bug_privacy_filter_with_decorator Return a SQL filter to limit returned bug tasks.
def search_value_to_storm_where_condition(comp, search_value):
Convert a search value to a Storm WHERE condition.
def search_bugs(pre_iter_hook, alternatives, just_bug_ids=False):
Return a ResultSet of BugTasks for the given search parameters.
Parameterspre_iter_hookAn optional pre-iteration hook used for eager loading bug targets for list views.
alternativesA sequence of BugTaskSearchParams instances, the results of which will be unioned. Only the first ordering is respected.
just_bug_idsReturn a ResultSet of bug IDs instead of BugTasks.
def _build_origin(join_tables, clauseTables, start_with):
Build the parameter list for Store.using().

Tables may appear simultaneously in join_tables and in clauseTables. This method ensures that each table appears exactly once in the returned sequence.

Parametersjoin_tablesA sequence of tables that should be joined as returned by _build_query(). Each element has the form (table, join), where table is the table to join and join is a Storm Join or LeftJoin instance.
clauseTablesA sequence of tables that should appear in the FROM clause of a query. The join condition is defined in the WHERE clause.
def _build_query(params):
Build and return an SQL query with the given parameters.

Also return the clauseTables and orderBy for the generated query.

ReturnsA query, the tables to query, ordering expression and a decorator to call on each returned row.
def _process_order_by(params):
Process the orderby parameter supplied to search().

This method ensures the sort order will be stable, and converting the string supplied to actual column names.

ReturnsA Storm order_by tuple.
def _require_params(params):
Undocumented
def _build_search_text_clause(params, fast=False):
Build the clause for searchtext.
def _build_status_clause(col, status):
Return the SQL query fragment for search by status.

Called from _build_query or recursively.

def _build_exclude_conjoined_clause(milestone):
Exclude bugtasks with a conjoined master.

This search option only makes sense when searching for bugtasks for a milestone. Only bugtasks for a project or a distribution can have a conjoined master bugtask, which is a bugtask on the project's development focus series or the distribution's currentseries. The project bugtask or the distribution bugtask will always have the same milestone set as its conjoined master bugtask, if it exists on the bug. Therefore, this prevents a lot of bugs having two bugtasks listed in the results. However, it is ok if a bug has multiple bugtasks in the results as long as those other bugtasks are on other series.

def _build_hardware_related_clause(params):
Hardware related SQL expressions and tables for bugtask searches.

Device related WHERE clauses are returned if params.hardware_bus, params.hardware_vendor_id, params.hardware_product_id are all not None.

ParametersparamsA BugTaskSearchParams instance.
Returns(tables, clauses) where clauses is a list of SQL expressions which limit a bugtask search to bugs related to a device or driver specified in search_params. If search_params contains no hardware related data, empty lists are returned.
def _build_blueprint_related_clause(params):
Find bugs related to Blueprints, or not.
def _build_pending_bugwatch_elsewhere_clause(params):
Return a clause for BugTaskSearchParams.pending_bugwatch_elsewhere
def _build_no_upstream_bugtask_clause(params):
Return a clause for BugTaskSearchParams.has_no_upstream_bugtask.
def _build_open_or_resolved_upstream_clause(params, statuses_for_watch_tasks, statuses_for_upstream_tasks):
Return a clause for BugTaskSearchParams.open_upstream or BugTaskSearchParams.resolved_upstream.
def _build_open_upstream_clause(params):
Return a clause for BugTaskSearchParams.open_upstream.
def _build_resolved_upstream_clause(params):
Return a clause for BugTaskSearchParams.open_upstream.
def _build_upstream_clause(params):
Return an clause for returning upstream data if the data exists.

This method will handles BugTasks that do not have upstream BugTasks as well as thoses that do.

def _build_tag_set_query(clauses):
Undocumented
def _build_tag_set_query_all(tags):
Return a Storm expression for bugs matching all given tags.
ParameterstagsAn iterable of valid tags without - or + and not wildcards.
ReturnsA Storm expression or None if no tags were provided.
def _build_tag_set_query_any(tags):
Return a Storm expression for bugs matching any given tag.
ParameterstagsAn iterable of valid tags without - or + and not wildcards.
ReturnsA Storm expression or None if no tags were provided.
def _build_tag_search_clause(tags_spec):
Return a tag search clause.
Parameterstags_specAn instance of any or all containing tag "specifications". A tag specification is a valid tag name optionally prefixed by a minus sign (denoting "not"), or an asterisk (denoting "any tag"), again optionally prefixed by a minus sign (and thus denoting "not any tag").
def get_bug_privacy_filter(user):
An SQL filter for search results that adds privacy-awareness.
def _nocache_bug_decorator(obj):
A pass through decorator for consistency.
See Also_get_bug_privacy_filter_with_decorator
def _make_cache_user_can_view_bug(user):
Curry a decorator for bugtask queries to cache permissions.
See Also_get_bug_privacy_filter_with_decorator
def _get_bug_privacy_filter_with_decorator(user):
Return a SQL filter to limit returned bug tasks.
ParametersuserThe user whose visible bugs will be filtered.
ReturnsA SQL filter, a decorator to cache visibility in a resultset that returns BugTask objects.
def get_bug_privacy_filter_terms(user, check_admin=True):
Return Storm terms for filtering bugs by visibility.

The same rules as get_bug_bulk_privacy_filter_terms, except designed and optimised for cases like bug searches, where we have a small number of users and a lot of bugs.

Also unlike get_bug_bulk_privacy_filter_terms, this constrains BugTaskFlat to user, rather than user to a bug column. It's up to callsites to work with BugTaskFlat.

Parametersusera Person ID value or column reference.
check_adminadd an admin role check. This is probably only necessary when checking multiple users; if you're only checking a specific one, you can do the admin check beforehand.
Returnsa Storm expression relating person to bug, where bug is visible to person.
def get_bug_bulk_privacy_filter_terms(person, bug):
Return Storm terms for filtering people by bug visibility.

The same rules as get_bug_privacy_filter_terms, except that it's designed and optimised for cases like bug notifications, where we have a small number of bug and need to check which people can see them.

Parameterspersona Person ID value or column reference.
buga Bug ID value or column reference.
Returnsa Storm expression relating person to bug, where bug is visible to person.
API Documentation for Launchpad, generated by pydoctor at 2018-02-22 00:00:13.