Skip to content

Commit

Permalink
Merge branch 'develop' of github.com-nossas:nossas/bonde-microservice…
Browse files Browse the repository at this point in the history
…s into release/v0.2.2
  • Loading branch information
Viviane committed Feb 20, 2020
2 parents f4f5673 + 1d40ef5 commit 7253899
Show file tree
Hide file tree
Showing 22 changed files with 3,685 additions and 4,392 deletions.
2 changes: 1 addition & 1 deletion packages/cli-mautic/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cli-mautic",
"dependencies": {
"@types/node": "^12.12.11",
"@types/node": "13.7.2",
"@types/prompts": "^2.0.3",
"@types/signale": "^1.2.1",
"@types/source-map-support": "^0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-zendesk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dependencies": {
"@types/debug": "^4.1.5",
"@types/express": "^4.17.2",
"@types/node": "^12.12.11",
"@types/node": "13.7.2",
"@types/signale": "^1.2.1",
"@types/source-map-support": "^0.5.0",
"@types/url-join": "^4.0.0",
Expand Down
47 changes: 23 additions & 24 deletions packages/solidarity-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,8 @@
"private": true,
"dependencies": {
"@google/maps": "^1.0.2",
"@hookstate/core": "^1.4.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.1.2",
"@turf/distance": "^6.0.1",
"@turf/turf": "^5.1.6",
"@types/body-parser": "^1.17.1",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.2",
"@types/history": "^4.7.3",
"@types/jest": "^24.0.23",
"@types/morgan": "^1.7.37",
"@types/node": "^12.12.17",
"@types/node-zendesk": "^1.4.0",
"@types/prop-types": "^15.7.3",
"@types/react": "^16.9.16",
"@types/react-dom": "^16.9.4",
"@types/react-map-gl": "^5.0.3",
"@types/react-router": "^5.1.3",
"@types/react-router-dom": "^5.1.3",
"@types/react-table": "^6.8.5",
"@types/styled-components": "^4.4.1",
"@types/testing-library__react": "^9.1.2",
"@types/url-join": "^4.0.0",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"bonde-styleguide": "^0.16.4-alpha.3",
Expand All @@ -49,7 +27,7 @@
"react-map-gl": "^5.1.3",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"react-scripts": "^3.4.0",
"react-spring": "^8.0.27",
"react-table": "6.10.3",
"styled-components": "^4.4.1",
Expand Down Expand Up @@ -90,6 +68,27 @@
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.4.0",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"@types/body-parser": "^1.17.1",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.2",
"@types/history": "^4.7.3",
"@types/jest": "^24.0.23",
"@types/morgan": "^1.7.37",
"@types/node": "13.7.2",
"@types/node-zendesk": "^1.4.0",
"@types/prop-types": "^15.7.3",
"@types/react": "^16.9.16",
"@types/react-dom": "^16.9.4",
"@types/react-map-gl": "^5.0.3",
"@types/react-router": "^5.1.3",
"@types/react-router-dom": "^5.1.3",
"@types/react-table": "^6.8.5",
"@types/styled-components": "^4.4.1",
"@types/testing-library__react": "^9.1.2",
"@types/url-join": "^4.0.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.1.2"
}
}
63 changes: 63 additions & 0 deletions packages/solidarity-client/server/all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

import getSolidarityTickets from './hasura/getSolidarityTickets'
import getSolidarityUsers from './hasura/getSolidarityUsers'
import { fuseTicketsAndUsers } from './utils'

const main = async (req, res, next) => {

const allUsers = await getSolidarityUsers({
query: `query {
solidarity_users(
where: {
longitude: {_is_null: false},
latitude: {_is_null: false},
organization_id: {_is_null: false}
}
) {
address
organization_id
user_id
atendimentos_concludos_calculado_
atendimentos_em_andamento_calculado_
disponibilidade_de_atendimentos
latitude
longitude
email
encaminhamentos
encaminhamentos_realizados_calculado_
name
phone
registration_number
occupation_area
whatsapp
data_de_inscricao_no_bonde
condition
tipo_de_acolhimento
}
}`
})

const allTickets = await getSolidarityTickets({
query: `query {
solidarity_tickets(
where: {
status: {_neq: "deleted"}
}
) {
requester_id
status_inscricao
status_acolhimento
ticket_id
created_at
status
subject
}
}`
})

const ticketsWithUser = fuseTicketsAndUsers(allUsers, allTickets)

res.json(ticketsWithUser)
}

export default main
7 changes: 4 additions & 3 deletions packages/solidarity-client/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import cors from 'cors'
import morgan from 'morgan'
import path from 'path'
import body_parser from 'body-parser'
import allTicketsAndUsers from './users/allTicketsAndUsers'
import all from './all'
import individuals from './individuals'
import forward from './forward'
import volunteersAvailable from './volunteersAvailable'
import locations from './locations'
Expand Down Expand Up @@ -36,8 +37,8 @@ app.use((err, req, res, next) => {
res.status(500).json({ message: 'an error occurred' })
})

app.get('/api/all', asyncMiddleware(allTicketsAndUsers))
app.get('/api/individuals', asyncMiddleware(allTicketsAndUsers))
app.get('/api/all', asyncMiddleware(all))
app.get('/api/individuals', asyncMiddleware(individuals))
app.get('/api/volunteers', asyncMiddleware(volunteersAvailable))
app.get('/api/locations', asyncMiddleware(locations))
app.get('/api/user', asyncMiddleware(user))
Expand Down
64 changes: 64 additions & 0 deletions packages/solidarity-client/server/individuals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

import getSolidarityUsers from './hasura/getSolidarityUsers'
import getSolidarityTickets from './hasura/getSolidarityTickets'
import { zendeskOrganizations } from './parse/index'
import { fuseTicketsAndUsers } from './utils'

const INDIVIDUAL = zendeskOrganizations.individual

const main = async (req, res, next) => {
const individualUsers = await getSolidarityUsers({
query: `query ($individual_id: bigint!){
solidarity_users(
where: {
longitude: {_is_null: false},
latitude: {_is_null: false},
organization_id: {_eq: $individual_id}
}
)
{
organization_id
user_id
latitude
longitude
email
name
phone
data_de_inscricao_no_bonde
tipo_de_acolhimento
address
}
}`,
variables: {
individual_id: INDIVIDUAL
}
})

const individualTickets = await getSolidarityTickets({
query: `query {
solidarity_tickets(
where: {
_or: [
{status: {_eq: "open"}},
{status: {_eq: "new"}}
],
status_acolhimento: {_eq: "solicitação_recebida"},
status: {_neq: "deleted"}
}
) {
status_acolhimento
status
subject
ticket_id
requester_id
created_at
}
}`
})

const ticketsWithUser = fuseTicketsAndUsers(individualUsers, individualTickets)

res.json(ticketsWithUser)
}

export default main
47 changes: 0 additions & 47 deletions packages/solidarity-client/server/users/allTicketsAndUsers.ts

This file was deleted.

104 changes: 0 additions & 104 deletions packages/solidarity-client/server/users/hasura.ts

This file was deleted.

Loading

0 comments on commit 7253899

Please sign in to comment.