Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

[SHARE-938][Improvement] Only display sources with data on sources page#193

Merged
chrisseto merged 2 commits intocos-archives:developfrom
laurenbarker:feature/match-source-number
Jul 6, 2017
Merged

[SHARE-938][Improvement] Only display sources with data on sources page#193
chrisseto merged 2 commits intocos-archives:developfrom
laurenbarker:feature/match-source-number

Conversation

@laurenbarker
Copy link
Copy Markdown
Contributor

Purpose

The number of sources on the sources page differ from the number on the discover page.

Changes

Filter API results based on an elastic aggregation.

Side effects

Only sources with data will display on the sources page. On staging and locally there might be only a few sources listed.

Ticket

https://openscience.atlassian.net/browse/SHARE-938

Copy link
Copy Markdown
Collaborator

@aaxelb aaxelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good 📽

What happens if elastic is down? Does this page show an error, or does it hang?

Comment thread app/controllers/sources.js Outdated
getQueryBody() {
let query = {
query_string: {
query: this.get('q') || '*'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever going to be a q on this page? You can just leave out the query part of the request, it'll match everything by default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops missed that 👍

Comment thread app/controllers/sources.js Outdated
}).then((json) => {
this.set('numberOfSources', json.meta.pagination.count);
this.get('sources').addObjects(json.data);
let tmpSources = json.data.filter(source => sourcesWithData.includes(source.attributes.longTitle));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be nicer if sourcesWithData were an object with titles as property names, so you could treat it like a set (longTitle in sourcesWithData) instead of iterating through the array over and over.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 @aaxelb.
You can use reduce to one line it.

Comment thread app/controllers/sources.js Outdated
this.loadElasticAggregations();
},

searchUrl: Ember.computed(function() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is from the discover page, but there's no reason for this to be a computed property. loadElasticAggregations should just call buildElasticCall (which probably doesn't even deserve to be a util... but there's no point trying to fix everything right now)

@laurenbarker
Copy link
Copy Markdown
Contributor Author

It will hang...should probs handle that 🐒

Use object instead of array for faster checking
@chrisseto chrisseto merged commit 5d49cbb into cos-archives:develop Jul 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants