Skip to content

Commit

Permalink
remove longDescription, add budget, income, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
asood123 authored and HipsterBrown committed Apr 26, 2018
1 parent 2fc162a commit 7cf112b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 16 additions & 4 deletions cron/daily/populate_search_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,35 @@ const populateIndex = () => {
},

attributes: {
exclude: ['settings', 'data']
exclude: ['settings', 'data', 'longDescription']
}, // exclude json fields to not fetch a lot of data
order: ['id']
})
.map(c => c.searchIndex)
.then(collectives => {
console.log("Collectives found", collectives.length);
/*
TODO: process data
- remove repeating words like 'we are on a mission'
- include other metadata: budget, amount available, backers, etc. (useful for ranking)
- include events (currently not included because no way to redirect directly to the event without parentCollective info). Might be easiest to include a publicUrl in the metadata
*/

// objectID is needed for algolia to build their own index
return collectives.map(el => Object.assign(el, { objectID: el.id }));
return Promise.map(collectives, c => {
Object.assign(c, { objectID: c.id })
return Promise.all([
c.getBackersCount(),
c.getBalance(),
c.getYearlyIncome()
])
.then(results => {
c.backersCount = results[0],
c.balance = results[1],
c.yearlyBudget = results[2]
return c;
})
})
})
.map(c => c.searchIndex)
.then(data => {
console.log("initializing search index");
const index = initializeClientandIndex(ALGOLIA_INDEX);
Expand Down
6 changes: 4 additions & 2 deletions server/models/Collective.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,14 @@ export default function(Sequelize, DataTypes) {
name: this.name,
description: this.description,
currency: this.currency,
longDescription: this.longDescription,
slug: this.slug,
mission: this.mission,
tags: this.tags,
locationName: this.locationName,
image: this.previewImage // Useful for displaying in results
image: this.previewImage, // Useful for displaying in results
balance: this.balance, // useful in ranking
yearlyBudget: this.yearlyBudget,
backersCount: this.backersCount
}
},
},
Expand Down

0 comments on commit 7cf112b

Please sign in to comment.