mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
999 B
39 lines
999 B
require('../core/worker')
|
|
const _ = require('lodash')
|
|
const { createApolloFetch } = require('apollo-fetch')
|
|
|
|
/* global WIKI */
|
|
|
|
WIKI.redis = require('../core/redis').init()
|
|
const apollo = createApolloFetch({
|
|
uri: 'https://graph.requarks.io'
|
|
})
|
|
|
|
module.exports = async (job) => {
|
|
WIKI.logger.info('Syncing locales with Graph endpoint...')
|
|
|
|
try {
|
|
const resp = await apollo({
|
|
query: `{
|
|
localization {
|
|
locales {
|
|
code
|
|
name
|
|
nativeName
|
|
isRTL
|
|
createdAt
|
|
updatedAt
|
|
}
|
|
}
|
|
}`
|
|
})
|
|
const locales = _.sortBy(_.get(resp, 'data.localization.locales', []), 'name').map(lc => ({...lc, isInstalled: (lc.code === 'en')}))
|
|
WIKI.redis.set('locales', JSON.stringify(locales))
|
|
|
|
WIKI.logger.info('Syncing locales with Graph endpoint: [ COMPLETED ]')
|
|
} catch (err) {
|
|
WIKI.logger.error('Syncing locales with Graph endpoint: [ FAILED ]')
|
|
WIKI.logger.error(err.message)
|
|
}
|
|
}
|