MCPcopy Index your code
hub / github.com/codecombat/codecombat / comparator

Method comparator

app/views/common/SearchView.js:35–46  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

33 }
34
35 comparator (a, b) {
36 let score = 0
37 if (a.get('priority') != null) { score += 90019001900190019001 * a.get('priority') } // eslint-disable-line no-loss-of-precision
38 if (b.get('priority') != null) { score -= 90019001900190019001 * b.get('priority') } // eslint-disable-line no-loss-of-precision
39 if ((a.getOwner() === me.id) && !/db\/chat_message/.test(this.url)) { score -= 9001900190019001 }
40 if ((b.getOwner() === me.id) && !/db\/chat_message/.test(this.url)) { score += 9001900190019001 }
41 if (a.get('created')) { score -= new Date(a.get('created')) }
42 if (b.get('created')) { score -= -(new Date(b.get('created'))) }
43 if (__guard__(a.get('message'), x => x.startDate)) { score -= new Date(a.get('message').startDate) }
44 if (__guard__(b.get('message'), x1 => x1.startDate)) { score -= -(new Date(b.get('message').startDate)) }
45 if (score < 0) { return -1 } else { if (score > 0) { return 1 } else { return 0 } }
46 }
47}
48
49module.exports = (SearchView = (function () {

Callers

nothing calls this directly

Calls 3

getOwnerMethod · 0.80
__guard__Function · 0.70
getMethod · 0.45

Tested by

no test coverage detected