diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-04-02 19:31:26 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-04-02 19:31:26 +0200 |
| commit | 78f15af7ac4b336c5e53178fd80e348151cc5f98 (patch) | |
| tree | a513f50882f9dc3e75ddf9d1a144d7149ec457e4 /scraper | |
| parent | 77e2b579bc42b6c36f82dba246561293049e73f8 (diff) | |
fix citation doublnig prob
Diffstat (limited to 'scraper')
| -rw-r--r-- | scraper/client/actions.js | 4 | ||||
| -rw-r--r-- | scraper/client/paper/paper.verify.js | 4 | ||||
| -rw-r--r-- | scraper/s2-geocode-server.py | 28 |
3 files changed, 20 insertions, 16 deletions
diff --git a/scraper/client/actions.js b/scraper/client/actions.js index b5c477f6..47ca6ff5 100644 --- a/scraper/client/actions.js +++ b/scraper/client/actions.js @@ -41,8 +41,8 @@ export const getVerificationsDataset = dataset => dispatch => ( api(dispatch, get, 'verifications', '/api/verifications/' + dataset, {}) ) -export const getVerification = sha256 => dispatch => ( - api(dispatch, get, 'verify', '/api/verify/' + sha256, {}) +export const getVerification = (dataset, sha256) => dispatch => ( + api(dispatch, get, 'verify', '/api/verify/' + dataset + '/' + sha256, {}) ) export const postVerification = data => dispatch => ( diff --git a/scraper/client/paper/paper.verify.js b/scraper/client/paper/paper.verify.js index 25117ff1..8794feb4 100644 --- a/scraper/client/paper/paper.verify.js +++ b/scraper/client/paper/paper.verify.js @@ -36,7 +36,7 @@ class PaperVerify extends Component { const { sha256 } = this.props.match.params this.props.actions.getInstitutions() this.props.actions.getAddress(sha256) - this.props.actions.getVerification(sha256) + this.props.actions.getVerification(this.props.api.paperInfo.dataset.key, sha256) const citationState = this.getCitationState(sha256) // console.log('DID MOUNT') this.setState(citationState) @@ -54,7 +54,7 @@ class PaperVerify extends Component { if (oldSha256 && sha256 !== oldSha256) { // console.log('update verification') this.props.actions.getAddress(sha256) - this.props.actions.getVerification(sha256) + this.props.actions.getVerification(this.props.api.paperInfo.dataset.key, sha256) const citationState = this.getCitationState(sha256) newState = { ...initialState, diff --git a/scraper/s2-geocode-server.py b/scraper/s2-geocode-server.py index 3aeda881..ad3efd5d 100644 --- a/scraper/s2-geocode-server.py +++ b/scraper/s2-geocode-server.py @@ -106,28 +106,32 @@ def list_dataset_verifications(dataset): dataset: verifications, }) -@app.route('/api/verify/<sha256>', methods=['GET']) -def find_verification(sha256): +@app.route('/api/verify/<dataset>/<sha256>', methods=['GET']) +def find_verification(dataset, sha256): worksheet = fetch_worksheet('verifications') + keys = worksheet.row_values(1) try: - cell = worksheet.find(sha256) + cells = worksheet.findall(sha256) except: return jsonify({ 'error': 'no_match' }) - if cell and cell.row: - keys = worksheet.row_values(1) + if not len(cells): + return jsonify({ + 'error': 'no_match' + }) + for cell in cells: values_list = worksheet.row_values(cell.row) lookup = {} for key, value in zip(keys, values_list): lookup[key] = value - return jsonify({ - 'paper': lookup, - }) - else: - return jsonify({ - 'error': 'no_match' - }) + if lookup['dataset'] == dataset: + return jsonify({ + 'paper': lookup, + }) + return jsonify({ + 'error': 'no_match' + }) @app.route('/api/verify/add', methods=['POST']) def add_verification(): |
