summaryrefslogtreecommitdiff
path: root/scraper/client/paper/paper.manager.js
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-04-18 16:56:39 +0200
committeradamhrv <adam@ahprojects.com>2019-04-18 16:56:39 +0200
commit64547d0d94e50ec7dc2c3c120d2b3ccbcaf4c038 (patch)
tree84a2d12c5b6d86ff457fc390bbf052c15cbc3405 /scraper/client/paper/paper.manager.js
parent651eeafb41bd7ad2f327bbfda2887032b90b71e9 (diff)
parent2e4daed06264f3dc3bbabd8fa4fc0d8ceed4c5af (diff)
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'scraper/client/paper/paper.manager.js')
-rw-r--r--scraper/client/paper/paper.manager.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/scraper/client/paper/paper.manager.js b/scraper/client/paper/paper.manager.js
index 8b25b1cc..2c5b79de 100644
--- a/scraper/client/paper/paper.manager.js
+++ b/scraper/client/paper/paper.manager.js
@@ -3,7 +3,7 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import * as actions from '../actions'
-import { USES_DATASET } from '../types'
+import { USES_DATASET, ADDRESS_TYPE_ENUM } from '../types'
import { Loader } from '../common'
@@ -16,13 +16,10 @@ class PaperManager extends Component {
if (this.props.match.params.key !== oldProps.match.params.key) {
this.props.actions.getPaperInfo(this.props.match.params.key)
}
- console.log('whoms?')
if (this.props.api.paperInfo.dataset !== oldProps.api.paperInfo.dataset && this.props.api.paperInfo.dataset && this.props.api.paperInfo.dataset.key) {
- console.log('vert?')
this.props.actions.getVerificationsDataset(this.props.api.paperInfo.dataset.key)
}
if (this.props.api.verifications !== oldProps.api.verifications && this.props.api.paperInfo.dataset) {
- console.log('updated?')
this.updateSortedCitations()
}
}
@@ -37,13 +34,25 @@ class PaperManager extends Component {
}
const citations = paperInfo.citations.concat(unknownCitations.citations)
let verifiedLookup = verifications[dataset.key] || {}
- const sortedCitations = citations.map(citation => [
+ // first sort by verification status,
+ // then by a combination of its geolocated sources and paper count.
+ // penalize papers with no PDF
+ const sortedCitations = citations
+ .map(citation => [
citation.title,
- verifiedLookup[citation.id] ? verifiedLookup[citation.id].uses_dataset : USES_DATASET.NO_DATA,
- citation.pdf.length,
+ verifiedLookup[citation.id]
+ ? verifiedLookup[citation.id].uses_dataset
+ : USES_DATASET.NO_DATA,
+ (citation.addresses || [])
+ .map(address => (ADDRESS_TYPE_ENUM[address.type] || 0))
+ .reduce((a, b) => (a + b), 0)
+ + (citation.pdf.length > 0
+ ? Math.max(citation.pdf.length, 2)
+ : -2
+ ),
citation
])
- .sort((a,b) => (b[1] - a[1] || b[2] - a[2] || (a[0].localeCompare(b[0]))))
+ .sort((a, b) => (b[1] - a[1] || b[2] - a[2] || (a[0].localeCompare(b[0]))))
.map(tup => ({
...tup[3],
verified: tup[1],