-
Notifications
You must be signed in to change notification settings - Fork 1
Issue 16: Add Rocket Employee Store #21
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
base: prod
Are you sure you want to change the base?
Changes from all commits
e46577f
34f5615
63f828b
67c8767
378a0d7
379c12f
40acb9f
08324c7
b25cd21
09eab04
b6f1126
33b4f06
1865458
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import _ from 'lodash' | ||
| import { WebClient } from '@slack/web-api' | ||
|
|
||
| const state = () => { | ||
| return {employeeHeadshots: null, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a whole bunch of formatting issues with this file again too. Let's pair soon and figure out the root cause of this. |
||
| employeesMissingFromSite: null | ||
| } | ||
| }; | ||
|
|
||
| const mutations = { | ||
| setEmployeeHeadshots(state, employeeHeadshots) { | ||
| state.employeeHeadshots = employeeHeadshots; | ||
| }, | ||
| setEmployeesMissingFromSite(state, payload) { | ||
| const uniqueEmployees = _.differenceBy(payload, state.employeeHeadshots, 'name') | ||
| state.employeesMissingFromSite = uniqueEmployees; | ||
| } | ||
| }; | ||
|
|
||
| const actions = { | ||
| async getContentfulEmployees ({ commit }) { | ||
| try{ | ||
| const employees = await this.$http.$get(this.$config.contentfulApiUrl) | ||
| const itemsFields = ['fields.name', 'fields.position', 'fields.profilePic.sys.id','sys.id'] | ||
|
RudyBecker marked this conversation as resolved.
|
||
| const itemsFilteredEmployees = _.map(employees.items, e => _.pick(e, itemsFields)) | ||
| const includesFields = ['fields.file.fileName', 'fields.file.url', 'sys.id'] | ||
| const includesFilteredEmployees = _.map(employees.includes.Asset, e => _.pick(e, includesFields)) | ||
| const mergedFilteredEmployees = _.values(_.merge(_.keyBy(includesFilteredEmployees,'sys.id'), _.keyBy(itemsFilteredEmployees,'fields.profilePic.sys.id' ) )) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha! I just realized this would be a great exercise for a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brandonaaskov
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const formattedFinalFilteredEmployees = _.map(mergedFilteredEmployees, item => { | ||
| return { | ||
| id:item.sys.id, | ||
| name:item.fields.name, | ||
| position:item.fields.position, | ||
| imageId:item.fields.profilePic.sys.id, | ||
| imageName:item.fields.file.fileName, | ||
| imageUrl:item.fields.file.url | ||
| } | ||
| } | ||
| ) | ||
| commit('setEmployeeHeadshots', formattedFinalFilteredEmployees) | ||
| } catch(error) { | ||
| console.error(error.message) | ||
| } | ||
| }, | ||
| async getSlackEmployees ({ commit }) { | ||
| try{ | ||
| const web = new WebClient(this.$config.slackBearerToken) | ||
| const slackEmployees = await web.users.list({team_id:'T03TAQHEU'}) | ||
| const formattedNotBotEmployees = _.reduce(slackEmployees.members, (list, user) => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to use reduce function. |
||
| if(!user.is_bot) { | ||
| list.push({"name": user.profile.real_name}) | ||
| } | ||
| return list | ||
| },[]) | ||
| commit('setEmployeesMissingFromSite', formattedNotBotEmployees) | ||
| } catch (error) { | ||
| console.error(error.message) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const getters = { | ||
| missingFromSite (state) { | ||
| return state.employeesMissingFromSite | ||
| } | ||
| }; | ||
|
|
||
| export default { state, mutations, actions, getters }; | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.