bug_tracker::bug::get_query (public)

 bug_tracker::bug::get_query [ -query_name query_name ]

Defined in packages/bug-tracker/tcl/bug-procs.tcl

Switches:
-query_name
(defaults to "bugs") (optional)
Returns:
The query

Partial Call Graph (max 5 caller/called nodes):
%3 bug_tracker::bug::get_list bug_tracker::bug::get_list (public) bug_tracker::bug::get_query bug_tracker::bug::get_query bug_tracker::bug::get_list->bug_tracker::bug::get_query bug_tracker::bug::get_multirow bug_tracker::bug::get_multirow (public) bug_tracker::bug::get_multirow->bug_tracker::bug::get_query ad_conn ad_conn (public) bug_tracker::bug::get_query->ad_conn db_map db_map (public) bug_tracker::bug::get_query->db_map template::adp_level template::adp_level (public) bug_tracker::bug::get_query->template::adp_level

Testcases:
No testcase defined.
Source code:

    upvar \#[template::adp_level] orderby orderby admin_p admin_p
    set package_id [ad_conn package_id]

    # Needed to handle ordering by categories
    set from_bug_clause "bt_bugs b"

    # Lars: This is a little hack because we actually need to alter the query to sort by category
    # but list builder currently doesn't support that.

    if { [info exists orderby] && [regexp {^category_(.*),.*$} $orderby match orderby_parent_id] } {
        append from_bug_clause [db_map orderby_category_from_bug_clause]

        # Branimir: The ORDER BY clause needs to be at the very end of the
        # query. That also means that we need to have in the select list every
        # column we want to order by.  Which columns we can afford to have in
        # the select list depends on which tables are we joining against.  BTW,
        # all these kludges are consequence of the initial (bad, IMHO) decision
        # to do the joins against cr_keywords in memory rather than in SQL.
        set more_columns ", kw_order.heading as heading"
    } else {
        set more_columns ""
    }

    return [db_map $query_name]
Generic XQL file:
<fullquery name="bug_tracker::bug::get_query.orderby_category_from_bug_clause">
    <querytext>
         left outer join cr_item_keyword_map km_order on (km_order.item_id = b.bug_id) 
         join cr_keywords kw_order on (km_order.keyword_id = kw_order.keyword_id and kw_order.parent_id = [ns_dbquotevalue $orderby_parent_id])
  </querytext>
</fullquery>

<fullquery name="bug_tracker::bug::get_query.bugs_pagination">
    <querytext>
    select b.bug_id,
           b.project_id,
           b.bug_number,
           b.summary,
           lower(b.summary) as lower_summary,
           b.comment_content,
           b.comment_format,
           b.component_id,
           b.creation_date,
           to_char(b.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_pretty,
           b.creation_user as submitter_user_id,
           submitter.first_names as submitter_first_names,
           submitter.last_name as submitter_last_name,
           submitter.email as submitter_email,
           lower(submitter.first_names) as lower_submitter_first_names,
           lower(submitter.last_name) as lower_submitter_last_name,
           lower(submitter.email) as lower_submitter_email,
           st.pretty_name as pretty_state,
           st.short_name as state_short_name,
           st.state_id,
           st.hide_fields,
           b.resolution,
           b.found_in_version,
           b.fix_for_version,
           b.fixed_in_version,
           cas.case_id
           $more_columns
    from $from_bug_clause,
         acs_users_all submitter,
         workflow_cases cas,
         workflow_case_fsm cfsm,
         workflow_fsm_states st 
    where submitter.user_id = b.creation_user
      and cas.workflow_id = :workflow_id
      and cas.object_id = b.bug_id
      and cfsm.case_id = cas.case_id
      and cfsm.parent_enabled_action_id is null
      and st.state_id = cfsm.current_state 
      [bug_tracker::user_bugs_only_where_clause]
    [template::list::filter_where_clauses -and -name "bugs"]
    [template::list::orderby_clause -orderby -name "bugs"]
  </querytext>
</fullquery>

<fullquery name="bug_tracker::bug::get_query.bugs">
    <querytext>
select q.*,
       km.keyword_id,
       assign_info.*
from (
  select b.bug_id,
         b.project_id,
         b.bug_number,
         b.summary,
         lower(b.summary) as lower_summary,
         b.comment_content,
         b.comment_format,
         b.component_id,
         to_char(b.creation_date,'YYYY-MM-DD HH24:MI:SS') as creation_date,
         to_char(b.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_pretty,
         b.creation_user as submitter_user_id,
         submitter.first_names as submitter_first_names,
         submitter.last_name as submitter_last_name,
         submitter.email as submitter_email,
         lower(submitter.first_names) as lower_submitter_first_names,
         lower(submitter.last_name) as lower_submitter_last_name,
         lower(submitter.email) as lower_submitter_email,
         st.pretty_name as pretty_state,
         st.short_name as state_short_name,
         st.state_id,
         st.hide_fields,
         b.resolution,
         b.found_in_version,
         b.fix_for_version,
         b.fixed_in_version,
         cas.case_id
         $more_columns
    from $from_bug_clause,
         acs_users_all submitter,
         workflow_cases cas,
         workflow_case_fsm cfsm,
         workflow_fsm_states st 
   where submitter.user_id = b.creation_user
     and cas.workflow_id = :workflow_id
     and cas.object_id = b.bug_id
     and cfsm.case_id = cas.case_id
     and cfsm.parent_enabled_action_id is null
     and st.state_id = cfsm.current_state
   [template::list::filter_where_clauses -and -name "bugs"]
   [bug_tracker::user_bugs_only_where_clause]
   [template::list::page_where_clause -and -name bugs -key bug_id]
) q
left outer join
  cr_item_keyword_map km
on (bug_id = km.item_id)
left outer join
  (select cru.user_id as assigned_user_id,
          aa.action_id,
          aa.case_id,
          wa.pretty_name as action_pretty_name,
          p.first_names as assignee_first_names,
          p.last_name as assignee_last_name
     from workflow_case_assigned_actions aa,
          workflow_case_role_user_map cru,
          workflow_actions wa,
	  persons p
    where aa.case_id = cru.case_id
      and aa.role_id = cru.role_id
      and cru.user_id = p.person_id
      and wa.action_id = aa.action_id
  ) assign_info
on (q.case_id = assign_info.case_id)
   [template::list::orderby_clause -orderby -name "bugs"]
  </querytext>
</fullquery>
packages/bug-tracker/tcl/bug-procs.xql

PostgreSQL XQL file:
packages/bug-tracker/tcl/bug-procs-postgresql.xql

Oracle XQL file:
packages/bug-tracker/tcl/bug-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: