Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings): allow to make a PR which changes both the settings and the data #179

Merged
merged 4 commits into from
Apr 13, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { index: mainIndex, client } = createAlgoliaIndex(c.indexName);
const { index: bootstrapIndex } = createAlgoliaIndex(c.bootstrapIndexName);
const stateManager = createStateManager(mainIndex);

setSettings(mainIndex)
Promise.resolve()
Copy link
Contributor

Choose a reason for hiding this comment

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

If only someone did a chore PR of moving to async/await... :D

.then(() => setSettings(bootstrapIndex))
.then(() => stateManager.check())
.then(bootstrap)
Expand Down Expand Up @@ -83,6 +83,7 @@ function infoDocs(offset, nbDocs, emoji) {

async function bootstrap(state) {
if (state.seq > 0 && state.bootstrapDone === true) {
await setSettings(mainIndex);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

setSettings will always be called when bootstrap is done

log.info('⛷ Bootstrap: done');
return state;
}
Expand Down Expand Up @@ -148,14 +149,13 @@ async function bootstrap(state) {

async function moveToProduction() {
log.info('🚚 starting move to production');
await client.copyIndex(c.indexName, c.bootstrapIndexName, [
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we no longer copy the settings from the prod index to the bootstrap index, but rely on the bootstrap index being correct


const currentState = await stateManager.get();
await client.copyIndex(c.bootstrapIndexName, c.indexName, [
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we should write await client.copyIndex(c.bootstrapIndexName, c.indexName) which will copy the data + all settings (+synonyms, query rules).

The current line will not copy the data

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh you're right, good of you for catching that!

'settings',
'synonyms',
'rules',
]);

const currentState = await stateManager.get();
await client.copyIndex(c.bootstrapIndexName, c.indexName);
await stateManager.save(currentState);

log.info('🗑 old bootstrap');
Expand Down