Skip to content

Commit

Permalink
LIMS-1458: Fix GitHub warnings (#841)
Browse files Browse the repository at this point in the history
* LIMS-1458: Do not access attributes directly. Use set() and get() instead

* LIMS-1458: Move function declaration to function body root

* LIMS-1458: Do not access attributes directly. Use set() and get() instead

* LIMS-1458: Unnecessary escape character

* LIMS-1458: Empty block statement, Unnecessary semicolon

* LIMS-1458: variable is already defined

* LIMS-1458: variable is already defined

* LIMS-1458: Do sorting on the server

* Update client/src/js/modules/dc/views/reprocess2.js

Co-authored-by: Guilherme Francisco <[email protected]>

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 6e51851 commit 72c4ca6
Show file tree
Hide file tree
Showing 27 changed files with 101 additions and 98 deletions.
8 changes: 4 additions & 4 deletions api/src/Page/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ function _beamlines()
$pdb = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, $replace as bl, count(p.pdbentryid) as count
FROM pdbentry p
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY $replace, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

$isp = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END as bl, count(p.pdbentryid) as count
FROM pdbentry p
Expand All @@ -284,8 +284,8 @@ function _beamlines()
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

foreach ($pdb as $i => &$s) {
$s['COUNT'] = intval(($s['COUNT']));
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/models/protein.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define(['backbone', 'markdown'], function(Backbone, markdown) {
},

refreshOptions: function() {
if (this.get('SEQUENCE')) this.attributes.SEQUENCEMD = markdown.toHTML(this.get('SEQUENCE'))
if (this.get('SEQUENCE')) this.set('SEQUENCEMD', markdown.toHTML(this.get('SEQUENCE')))
},

validation: {
Expand Down
8 changes: 4 additions & 4 deletions client/src/js/models/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ define(['backbone', 'backbone-validation', 'luxon'], function(Backbone, BackBone
addDate: function() {
var { DateTime } = luxon

this.attributes.ENISO = DateTime.fromISO(this.get('ENISO'), { zone: this.dateTimeZone })
this.attributes.STISO = DateTime.fromISO(this.get('STISO'), { zone: this.dateTimeZone })
this.attributes.LEN = Number(this.attributes.ENISO.diff(this.attributes.STISO)/(3600*1000)).toFixed(2);
this.attributes.VISITDETAIL = this.get('VISIT')+' ('+this.get('BL')+': '+this.get('ST')+')'
this.set('ENISO', DateTime.fromISO(this.get('ENISO'), { zone: this.dateTimeZone }))
this.set('STISO', DateTime.fromISO(this.get('STISO'), { zone: this.dateTimeZone }))
this.set('LEN', Number(this.get('ENISO').diff(this.get('STISO'))/(3600*1000)).toFixed(2))
this.set('VISITDETAIL', this.get('VISIT')+' ('+this.get('BL')+': '+this.get('ST')+')')
},

dateTimeZone: 'Europe/London'
Expand Down
31 changes: 15 additions & 16 deletions client/src/js/modules/cell/views/beamlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,27 @@ define(['marionette', 'utils',
})

var bl = []
var data = {}
_.each(bls, function(i, b) {
data[b] = {}
bl.push(b)
ticks.push([bl.length-1, b])
_.each(years, function(x, y) {
data[b][y] = 0
})
})

_.each(this.model.get('data')[did], function(v, i) {
var y = yrs.indexOf(v.YEAR)
var b = bl.indexOf(v.BL)
//console.log('d', y, b)
d[y].data.push([b, v.COUNT])
})

function ascsort(a,b) {
if (a[0] == b[0]) return 0
else return (a[0] < b[0]) ? -1 : 1
}

_.each(d, function(d,i) {
d.data.sort(ascsort)
})
_.each(this.model.get('data')[did], function(v, i) {
data[v.BL][v.YEAR] = v.COUNT
})

console.log(d)
_.each(data, function(el, beamline) {
_.each(el, function(count, year) {
var y = yrs.indexOf(year)
var b = bl.indexOf(beamline)
d[y].data.push([b, count])
})
})

var options = {
series: {
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/modules/dc/models/autointegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ define(['backbone'], function(Backbone){
var shells = this.get('SHELLS')
if (!shells) return

this.attributes.CLASS = { RMERGE: {}, RMEAS: {}, COMPLETENESS: {} }
this.set('CLASS', { RMERGE: {}, RMEAS: {}, COMPLETENESS: {} })
_.each(['overall', 'innerShell', 'outerShell'], function(k) {
var c = shells[k] ? shells[k].COMPLETENESS : null
this.attributes.CLASS.COMPLETENESS[k] = c > 95 ? 'active' : (c > 80 ? 'minor' : 'inactive')
this.set('CLASS[COMPLETENESS[k]]', c > 95 ? 'active' : (c > 80 ? 'minor' : 'inactive'))

var r = shells[k] ? shells[k].RMEAS : null
this.attributes.CLASS.RMEAS[k] = r < 0.5 ? 'active' : (r < 0.6 ? 'minor' : 'inactive')
this.set('CLASS[RMEAS[k]]', r < 0.5 ? 'active' : (r < 0.6 ? 'minor' : 'inactive'))
}, this)
},

Expand Down
8 changes: 4 additions & 4 deletions client/src/js/modules/dc/models/dccomment.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ define(['backbone', 'markdown'], function(Backbone, markdown) {
},

addDate: function() {
this.attributes.CREATETIMEISO = new Date(this.get('CREATETIME'))
this.attributes.MODTIMEISO = new Date(this.get('MODTIME'))
if (this.get('COMMENTS')) this.attributes.COMMENTSMD = markdown.toHTML(this.get('COMMENTS'))
this.set('CREATETIMEISO', new Date(this.get('CREATETIME')))
this.set('MODTIMEISO', new Date(this.get('MODTIME')))
if (this.get('COMMENTS')) this.set('COMMENTSMD', markdown.toHTML(this.get('COMMENTS')))
}

})

})
})
9 changes: 4 additions & 5 deletions client/src/js/modules/dc/views/reprocess2.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ define(['backbone', 'marionette', 'views/dialog',
if (e) e.preventDefault()

if (this.aps.length) {
var e = this.aps.at(0)
var c = e.get('CELL')
const a = this.aps.at(0)
const c = a.get('CELL')

this.ui.a.val(c['CELL_A']).trigger('change')
this.ui.b.val(c['CELL_B']).trigger('change')
Expand All @@ -172,7 +172,7 @@ define(['backbone', 'marionette', 'views/dialog',
this.ui.be.val(c['CELL_BE']).trigger('change')
this.ui.ga.val(c['CELL_GA']).trigger('change')

this.ui.sg.val(e['SG']).trigger('change')
this.ui.sg.val(a['SG']).trigger('change')
}
},

Expand Down Expand Up @@ -300,11 +300,11 @@ define(['backbone', 'marionette', 'views/dialog',
}

var self = this
var reqs = []
// Integrate individually
if (this.ui.ind.is(':checked')) {
var jobs = 0

var reqs = []
var rps = []
_.each(s, function(sw) {
var p = this.pipelines.findWhere({ VALUE: sw.get('PIPELINE') })
Expand Down Expand Up @@ -405,7 +405,6 @@ define(['backbone', 'marionette', 'views/dialog',
return
}

var reqs = []
reqs.push(reprocessing.save({}, {
success: function() {
var reprocessingparams = new ReprocessingParameters()
Expand Down
8 changes: 4 additions & 4 deletions client/src/js/modules/dc/views/reprocessoverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@ define(['marionette',
},

render: function() {
var columns = [
var pcolumns = [
{ name: 'PARAMETERKEY', label: 'Key', cell: 'string', editable: false },
{ name: 'PARAMETERVALUE', label: 'Value', cell: 'string', editable: false },
]

var ptable = new TableView({
collection: this.params,
columns: columns,
columns: pcolumns,
loading: false,
pages: false,
backgrid: { emptyText: 'No parameters found' },
})

this.$el.html(ptable.render().$el)

var columns = [
var scolumns = [
{ label: 'Files', cell: table.TemplateCell, editable: false, template: '<a href="/dc/visit/<%-VISIT%>/id/<%-DATACOLLECTIONID%>"><%-IMAGEDIRECTORY%><%-IMAGEPREFIX%>_<%-DATACOLLECTIONNUMBER%></a>' },
{ label: 'Image #', cell: table.TemplateCell, editable: false, template: '<%-STARTIMAGE%> - <%-ENDIMAGE%>' },
]

var stable = new TableView({
collection: this.sweeps,
columns: columns,
columns: scolumns,
loading: false,
pages: false,
backgrid: { emptyText: 'No image sweeps found' },
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/modules/dc/views/samplechanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ define(['marionette', 'utils/canvas', 'utils',
// Draw Grid
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
//this.ctx.drawImage(this.numbers, 0, 0, this.canvas.width, this.canvas.height)
for (var j = 0; j < this.sc; j++) {
for (var n = 0; n < this.sc; n++) {
this.ctx.fillStyle = '#000'
this.ctx.font = "11px Arial"
this.ctx.lineWidth = 1
this.ctx.fillText(j+1,10,this.sh*j+this.tpad+4);
this.ctx.fillText(n+1,10,this.sh*n+this.tpad+4);
}

for (var i = 0; i < this.positions; i++) {
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/modules/fault/models/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ define(['backbone'], function(Backbone) {
},
initialize: function(options) {
this.on('change', this._add_id, this)
this._add_id()
this._add_id()
},
urlRoot: '/fault/com',
idAttribute: 'COMPONENTID',

_add_id: function() {
this.attributes.ID = this.get('COMPONENTID')
this.set('ID', this.get('COMPONENTID'))
},

})

})
})
8 changes: 4 additions & 4 deletions client/src/js/modules/fault/models/fault.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ define(['backbone', 'markdown', 'models/wfile'], function(Backbone, markdown, Fi
},

refreshOptions: function() {
this.attributes.RESOLVEDTEXT = this.resolvedOptions[this.get('RESOLVED')]
this.attributes.BEAMTIMELOSTTEXT = this.btlOptions[this.get('BEAMTIMELOST')]
this.set('RESOLVEDTEXT', this.resolvedOptions[this.get('RESOLVED')])
this.set('BEAMTIMELOSTTEXT', this.btlOptions[this.get('BEAMTIMELOST')])

if (this.get('DESCRIPTION')) this.attributes.DESCRIPTIONMD = markdown.toHTML(this.get('DESCRIPTION'))
if (this.get('RESOLUTION')) this.attributes.RESOLUTIONMD = markdown.toHTML(this.get('RESOLUTION'))
if (this.get('DESCRIPTION')) this.set('DESCRIPTIONMD', markdown.toHTML(this.get('DESCRIPTION')))
if (this.get('RESOLUTION')) this.set('RESOLUTIONMD', markdown.toHTML(this.get('RESOLUTION')))
},

validation: {
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/modules/fault/models/subcomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ define(['backbone'], function(Backbone) {
},
initialize: function(options) {
this.on('change', this._add_id, this)
this._add_id()
this._add_id()
},
urlRoot: '/fault/scom',
idAttribute: 'SUBCOMPONENTID',
_add_id: function() {
this.attributes.ID = this.get('SUBCOMPONENTID')
this.set('ID', this.get('SUBCOMPONENTID'))
},
})
})
})
4 changes: 2 additions & 2 deletions client/src/js/modules/fault/models/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ define(['backbone'], function(Backbone) {
urlRoot: '/fault/sys',
idAttribute: 'SYSTEMID',
_add_id: function() {
this.attributes.ID = this.get('SYSTEMID')
this.set('ID', this.get('SYSTEMID'))
},
})

})
})
5 changes: 3 additions & 2 deletions client/src/js/modules/imaging/views/queuecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,11 @@ define(['marionette',
},

applyModel: function(modelParameter, isLimitedToSelected) {
var models = null
if (isLimitedToSelected) {
var models = this.qsubsamples.where({ isGridSelected: true })
models = this.qsubsamples.where({ isGridSelected: true })
} else {
var models = this.qsubsamples.fullCollection.toArray()
models = this.qsubsamples.fullCollection.toArray()
}
_.each(models, function(model) {
if (modelParameter.get('EXPERIMENTKIND') !== model.get('EXPERIMENTKIND')) return
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/shipment/models/containerreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(['backbone', 'markdown', 'models/wfile'], function(Backbone, markdown, Fi
},

refreshOptions: function() {
if (this.get('REPORT')) this.attributes.REPORTMD = markdown.toHTML(this.get('REPORT'))
if (this.get('REPORT')) this.set('REPORTMD', markdown.toHTML(this.get('REPORT')))
},

validation: {
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/modules/shipment/models/dewarreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(['backbone', 'markdown', 'models/wfile'], function(Backbone, markdown, Fi
},

refreshOptions: function() {
if (this.get('REPORT')) this.attributes.REPORTMD = markdown.toHTML(this.get('REPORT'))
if (this.get('REPORT')) this.set('REPORTMD', markdown.toHTML(this.get('REPORT')))
},

validation: {
Expand All @@ -37,4 +37,4 @@ define(['backbone', 'markdown', 'models/wfile'], function(Backbone, markdown, Fi
}
}
}, File))
})
})
6 changes: 3 additions & 3 deletions client/src/js/modules/shipment/views/containerregistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ define(['marionette',
this.listenTo(this.proposals, 'backgrid:selected', this.selectModel, this)
this.proposals.fetch()

var columns = [
var columns2 = [
{ label: '', cell: 'select-row', headerCell: 'select-all', editable: false },
{ name: 'PROPOSALCODE', label: 'Code', cell: 'string', editable: false },
{ name: 'PROPOSALNUMBER', label: 'Number', cell: 'string', editable: false },
Expand All @@ -126,7 +126,7 @@ define(['marionette',

this.table2 = new TableView({
collection: this.proposals,
columns: columns, tableClass: 'proposals', filter: 's', search: options.params.s, loading: true, noPageUrl: true, noSearchUrl: true,
columns: columns2, tableClass: 'proposals', filter: 's', search: options.params.s, loading: true, noPageUrl: true, noSearchUrl: true,
backgrid: { emptyText: 'No proposals found' }
})

Expand Down Expand Up @@ -175,4 +175,4 @@ define(['marionette',
}
})

})
})
8 changes: 4 additions & 4 deletions client/src/js/modules/shipment/views/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ define(['marionette',
var d = new Date()
_.each([d.getFullYear(), d.getFullYear()-1], function(y) {
_.each(_.range(1,13), function(m) {
var m = (m < 10 ? ('0'+m) : m)+'-'+y
m = (m < 10 ? ('0'+m) : m)+'-'+y
this.ui.month.append('<option value="'+m+'">'+m+'</option>')
}, this)
}, this)


var m = d.getMonth() +1
var cur = (m < 10 ? ('0'+m) : m)+'-'+d.getFullYear()
var mon = d.getMonth() +1
var cur = (mon < 10 ? ('0'+mon) : mon)+'-'+d.getFullYear()
this.ui.month.val(cur)

var columns = [
Expand Down Expand Up @@ -95,4 +95,4 @@ define(['marionette',

})

})
})
Loading

0 comments on commit 72c4ca6

Please sign in to comment.