roam/aweber/20210914143542-sites_subscriber_search.org

43 lines
2.2 KiB
Org Mode
Raw Normal View History

2021-09-15 03:50:54 +00:00
:PROPERTIES:
:ID: d9cb2b55-3b0e-4ab3-8369-f71ebc3cd882
:END:
#+title: Sites Subscriber Search
* Sorting
Added: [2020-04-14 Tue 13:34]
The current sites search code includes the following functioning code for
setting a sort order on a search based on form input:
https://gitlab.aweber.io/CP/applications/sites/blob/52d1d944854554c5818ef9a46c8a12493599eb55/aweber_app/controllers/queries_controller.php#L386-402
#+begin_src php :exports code :eval never
// Look up the column for the order by clause. There are no SQL column name values passed publicly.
if (!empty($this->data['SearchOrder']['SearchInput'])){
$this->SearchInput->recursive = -1;
if ($time = $this->SearchMutex->lock($aId, '6')) {
$orderCol = $this->SearchInput->find(array('SearchInput.id' => $this->data['SearchOrder']['SearchInput']));
$this->SearchMutex->unlock($aId, '6', $time);
}
if (!empty($orderCol['SearchInput']['column'])){
//Case-insensitive text sorting.
// Lower text fields so that ordering is case insensitive. SearchInputs 5, 23, and 24 are actually integers, despite
// having a text search input. refs #3275
if($orderCol['SearchInput']['input_type'] == 'text' && !in_array($orderCol['SearchInput']['id'], array(5,23,24))) {
$orderCol['SearchInput']['column'] = 'lower('.$orderCol['SearchInput']['column'].')';
}
$this->data['SearchOrder']['column'] = $orderCol['SearchInput']['column'];
}
}
#+end_src
- It is saved with the segment
- It is passed back to the front-end when loading a saved segment
- The =SearchCriteria= class incorporates the selected ordering and column when
building its query for a targeted search database.
- The broadcast segment service ignores the selected ordering, opting for its
own for deliverability reasons.
- All search inputs NOT in the analytics database are available for sorting (https://gitlab.aweber.io/CP/applications/sites/blob/f7ea2e9431e3ed2e694730f6446b4b3828d7c8fe/aweber_app/views/helpers/search_form.php#L54-62).
- Performance degrades with list size, likely due to memory constraints and
unindexed sort fields
(https://www.cybertec-postgresql.com/en/postgresql-improving-sort-performance/).