diff --git a/api/src/Page/Proposal.php b/api/src/Page/Proposal.php index fcc019322..f8207ed2f 100644 --- a/api/src/Page/Proposal.php +++ b/api/src/Page/Proposal.php @@ -393,8 +393,7 @@ function _get_visits($visit = null, $output = true) } if ($this->has_arg('s')) { - $where .= " AND (s.visit_number LIKE :" . (sizeof($args) + 1) . " OR s.beamlinename LIKE :" . (sizeof($args) + 2) . ")"; - array_push($args, $this->arg('s')); + $where .= " AND s.visit_number LIKE :" . (sizeof($args) + 1); array_push($args, $this->arg('s')); } @@ -436,9 +435,7 @@ function _get_visits($visit = null, $output = true) $order = 's.startdate DESC'; if ($this->has_arg('sort_by')) { - $cols = array('ST' => 's.startdate', 'EN' => 's.enddate', 'VIS' => 's.visit_number', 'BL' => 's.beamlinename', - 'LC' => 's.beamlineoperator', 'COMMENT' => 's.comments', 'ERA' => 's.riskrating', - 'SESSIONTYPE' => 'sessiontype', 'DCCOUNT' => 'dccount'); + $cols = array('ST' => 's.startdate', 'EN' => 's.enddate', 'VIS' => 's.visit_number', 'BL' => 's.beamlinename', 'LC' => 's.beamlineoperator', 'COMMENT' => 's.comments'); $dir = $this->has_arg('order') ? ($this->arg('order') == 'asc' ? 'ASC' : 'DESC') : 'ASC'; if (array_key_exists($this->arg('sort_by'), $cols)) $order = $cols[$this->arg('sort_by')] . ' ' . $dir; @@ -472,7 +469,6 @@ function _get_visits($visit = null, $output = true) s.beamcalendarid, CONCAT(p.proposalcode, p.proposalnumber) AS proposal, COUNT(shp.personid) AS persons, - COUNT(distinct dc.datacollectionid) AS dccount, s.proposalid FROM BLSession s INNER JOIN proposal p ON p.proposalid = s.proposalid @@ -480,14 +476,35 @@ function _get_visits($visit = null, $output = true) LEFT OUTER JOIN session_has_person shp ON shp.sessionid = s.sessionid LEFT OUTER JOIN beamlinesetup bls on bls.beamlinesetupid = s.beamlinesetupid LEFT OUTER JOIN beamcalendar bc ON bc.beamcalendarid = s.beamcalendarid - LEFT OUTER JOIN datacollectiongroup dcg ON dcg.sessionid = s.sessionid - LEFT OUTER JOIN datacollection dc ON dcg.datacollectiongroupid = dc.datacollectiongroupid $where GROUP BY s.sessionid ORDER BY $order", $args); + $ids = array(); + $wcs = array(); + foreach ($rows as $r) { + array_push($ids, $r['SESSIONID']); + array_push($wcs, 'dcg.sessionid=:' . sizeof($ids)); + } + + $dcs = array(); + if (sizeof($ids)) { + $where = implode(' OR ', $wcs); + $tdcs = $this->db->pq("SELECT count(dc.datacollectionid) as c, dcg.sessionid + FROM datacollection dc + INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid + WHERE $where GROUP BY dcg.sessionid", $ids); + foreach ($tdcs as $t) + $dcs[$t['SESSIONID']] = $t['C']; + } + foreach ($rows as &$r) { + $dc = array_key_exists($r['SESSIONID'], $dcs) ? $dcs[$r['SESSIONID']] : 0; + $r['COMMENT'] = $r['COMMENTS']; + $r['DCCOUNT'] = $dc; + $bl_type = $this->_get_type_from_beamline($r['BL']); + $r['TYPE'] = $bl_type ? $bl_type : 'gen'; } diff --git a/client/src/js/modules/visits/views/visit_list.vue b/client/src/js/modules/visits/views/visit_list.vue index 26c019ee9..c3feef51a 100644 --- a/client/src/js/modules/visits/views/visit_list.vue +++ b/client/src/js/modules/visits/views/visit_list.vue @@ -16,16 +16,15 @@
@@ -121,25 +120,21 @@ export default { visits: [], dewars: [], searchVisit : '', - orderBy: '', - order: 1, headers: [ { key: "STARTDATE", - title: 'Start', - order: 'ST' + title: 'Start' }, { key: "ENDDATE", - title: 'End', - order: 'EN' + title: 'End' }, { key: "VIS", title: 'Number' }, { - key: "BL", + key: "BEAMLINENAME", title: 'Beamline' }, { @@ -152,8 +147,7 @@ export default { }, { key: "UNIQUELCS", - title: 'Local Contact', - order: 'LC' + title: 'Local Contact' }, { key: "COMMENTS", @@ -184,7 +178,6 @@ export default { window.location.href = '/proposals/'; } this.fetchData() - this.fetchData = _.debounce(this.fetchData, 500) }, methods: { async fetchData() { @@ -195,18 +188,8 @@ export default { page: this.currentPage, per_page: this.pageSize, prop: this.proposal, - order: 'order', - directions: { - '-1': 'asc', - '1': 'desc', - }, - }; - this.visitCollection.state = { - sortKey: 'sort_by', - order: this.order, + s: this.searchVisit, }; - if (this.searchVisit) this.visitCollection.queryParams.s = this.searchVisit; - if (this.orderBy) this.visitCollection.queryParams.sort_by = this.orderBy; const results = await this.$store.dispatch('getCollection', this.visitCollection); this.visits = results.toJSON().map((e) => { @@ -276,15 +259,6 @@ export default { window.location.href = 'dc/visit/' + this.proposal + '-' + visit.VIS; } }, - headerClick(event) { - if (this.orderBy === event.target.id) { - this.order = -this.order; - } else { - this.order = 1; - } - this.orderBy = event.target.id; - this.fetchData(); - }, handleFocusOut(visit) { // if click outside of active input box then input returns to text if(visit.clicked) {
- - {{value.title}} + class="tw-w-1/8 tw-bg-table-header-background tw-text-table-header-color tw-font-bold tw-py-2 tw-text-center"> + {{value.title}}