Skip to content

Commit

Permalink
Add nation sync to procfile
Browse files Browse the repository at this point in the history
  • Loading branch information
saikat committed Jun 14, 2017
1 parent ff737a7 commit b5ee9b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 49 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
web: node ./src
worker: npm run worker
syncer: npm run nation-sync
1 change: 1 addition & 0 deletions dev-tools/Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
server: npm run dev-start
redis: redis-server
worker: npm run dev-worker
syncer: npm run nation-sync
52 changes: 3 additions & 49 deletions src/nation-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,6 @@ redisClient.on("error", function (err) {

let CONS_GROUP_MAP = {}

async function createConsGroups() {
await refreshConsGroups()
const tagPrefixWhitelist = [
'Action:',
'Availability:',
'Skill:'
]
let allTags = []
let res = await nationbuilder.makeRequest('GET', 'tags', { params: {
limit: 100
}})
while (true) {
const tags = res.data.results
allTags = allTags.concat(tags)
if (res.data.next) {
const next = res.data.next.split('?')
res = await nationbuilder.makeRequest('GET', res.data.next, { params: {
limit: 100
}})
} else {
break
}
}
allTags = allTags.map((tag) => tag.name)
const filteredTags = allTags.filter((tag) => {
let foundPrefix = false
tagPrefixWhitelist.forEach((prefix) => {
if (tag.indexOf(prefix) === 0) {
foundPrefix = true
}
})
return foundPrefix
})
for (let index = 0; index < filteredTags.length; index++) {
const group = filteredTags[index]
if (!CONS_GROUP_MAP.hasOwnProperty(group)) {
console.log(`Creating ${group}...`)
await bsd.createConstituentGroups([group])
await refreshConsGroups()
}
}
}

async function refreshConsGroups() {
log.info('Refreshing cons groups...')
CONS_GROUP_MAP = {}
Expand Down Expand Up @@ -325,15 +282,12 @@ async function syncEvents() {
}

async function sync() {
/*
console.log('start')
log.info('Starting sync...')
await refreshConsGroups()
await syncPeople()
await syncEvents()
setTimeout(sync, 2000)
console.log('done')
*/
await createConsGroups()
setTimeout(sync, 600000)
log.info('Done syncing!')
}

const timezoneMap = {
Expand Down

0 comments on commit b5ee9b2

Please sign in to comment.