Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
feather
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
feather
Commits
ae8e1498
Commit
ae8e1498
authored
May 18, 2018
by
Cole Bemis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: Refactor algolia script to reindex data atomically
parent
962870d5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
sync-algolia.js
bin/sync-algolia.js
+17
-5
No files found.
bin/sync-algolia.js
View file @
ae8e1498
...
...
@@ -18,20 +18,32 @@ function syncAlgolia() {
// ALGOLIA_ADMIN_KEY must be added as an environment variable in Travis CI
const
client
=
algolia
(
ALGOLIA_APP_ID
,
process
.
env
.
ALGOLIA_ADMIN_KEY
);
// Initialize the target and temporary indexes
const
index
=
client
.
initIndex
(
'
icons
'
);
const
indexTmp
=
client
.
initIndex
(
'
icons_tmp
'
);
// Copy the settings, synonyms and rules (but not the records)
// of the target index into the temporary index
client
.
copyIndex
(
index
.
indexName
,
indexTmp
.
indexName
,
[
'
settings
'
,
'
synonyms
'
,
'
rules
'
,
]);
// Push data to the temporary index
const
records
=
Object
.
keys
(
icons
).
map
(
name
=>
({
name
,
tags
:
tags
[
name
]
||
[],
}));
index
.
clearIndex
(
(
err
,
content
)
=>
{
index
Tmp
.
addObjects
(
records
,
(
err
,
content
)
=>
{
if
(
err
)
throw
err
;
console
.
log
(
content
);
});
index
.
addObjects
(
records
,
(
err
,
content
)
=>
{
// Move the temporary index to the target index
client
.
moveIndex
(
indexTmp
.
indexName
,
index
.
indexName
,
(
err
,
content
)
=>
{
if
(
err
)
throw
err
;
console
.
log
(
content
);
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment