Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a7ada48
Adiciona validação, associações e testes para o model Key Word
CaioFML Apr 2, 2020
2a9ae70
update chatbot branch
toticavalcanti Apr 2, 2020
4829e58
improve README.md
toticavalcanti Apr 2, 2020
9f323eb
improve README.md
toticavalcanti Apr 2, 2020
2757cd9
improve README.md
toticavalcanti Apr 2, 2020
156de6d
improve README.md
toticavalcanti Apr 2, 2020
3b451f1
improve README.md
toticavalcanti Apr 2, 2020
3a1d93c
improve README.md
toticavalcanti Apr 2, 2020
86a5348
improve README.md
toticavalcanti Apr 2, 2020
fda3555
improve README.md
toticavalcanti Apr 2, 2020
25b18ac
improve README.md
toticavalcanti Apr 2, 2020
81aab94
improve README.md
toticavalcanti Apr 2, 2020
52756ba
service of create user created
lsolino Apr 3, 2020
8ac4757
updated search service
lsolino Apr 3, 2020
fa17a1e
service of create alert created
lsolino Apr 3, 2020
b9d9838
creating key_word if not exists in alert_service
lsolino Apr 4, 2020
167ace6
services of alert list and alert delete created
lsolino Apr 4, 2020
762f6f4
fix some git conflits
toticavalcanti Apr 4, 2020
bb4378d
sync branch local remote
toticavalcanti Apr 4, 2020
baba0ce
sync branch local remote
toticavalcanti Apr 4, 2020
3dfe4d4
set models/key_word
toticavalcanti Apr 4, 2020
cc82269
set models/key_word
toticavalcanti Apr 4, 2020
5d972cd
create spec/models/key_word_spec.rb
toticavalcanti Apr 5, 2020
f0da14b
merge with controller_jobs branch
toticavalcanti Apr 5, 2020
58be1c9
Merge branch 'master' of github.com:OneBitCodeBlog/programador-homeof…
CaioFML Apr 5, 2020
c680ff7
determina rotas para controller job
CaioFML Apr 5, 2020
a834684
add active_model_serializer
CaioFML Apr 5, 2020
287ee57
Adiciona inflexão API
CaioFML Apr 5, 2020
d1eb383
Defini rotas para Jobs
CaioFML Apr 5, 2020
0fb3586
Serializa Job
CaioFML Apr 5, 2020
254979a
Cria Factory para Job
CaioFML Apr 5, 2020
4427b38
Adiciona default para contract
CaioFML Apr 5, 2020
359967c
corrige job_serializer
CaioFML Apr 5, 2020
f81c7b5
Adiciona para rodar testes aleatoriamente
CaioFML Apr 5, 2020
9ef2f3e
corrige job serializer
CaioFML Apr 5, 2020
44cce51
testa action index em request spec
CaioFML Apr 5, 2020
a87ed63
cria factory para job_key_words e key_words
CaioFML Apr 5, 2020
393886e
Adiciona adapter para :json_api
CaioFML Apr 5, 2020
87cc6a3
Adiciona kaminari
CaioFML Apr 5, 2020
d1b4486
Chama classe correta do ams
CaioFML Apr 5, 2020
90efe1d
testes index completos
CaioFML Apr 5, 2020
18b6c91
cria #show e testes de request para show
CaioFML Apr 5, 2020
c8d0479
Merge branch 'master' into controller_jobs
CaioFML Apr 5, 2020
8291fd0
merge with controller_jobs branch
toticavalcanti Apr 5, 2020
87e9604
merging chatbot with controller_jobs
toticavalcanti Apr 5, 2020
fd0d452
merging chatbot with controller_jobs
toticavalcanti Apr 5, 2020
5da2d14
merging chatbot with controller_jobs
toticavalcanti Apr 5, 2020
682650d
fix some merge conflicts
toticavalcanti Apr 5, 2020
0b1df5f
fix some merge conflicts
toticavalcanti Apr 5, 2020
1a314b4
fix some merge conflicts in spec/spec_helper.rb
toticavalcanti Apr 5, 2020
d079a46
Merge branch 'chatbot' of github.com:OneBitCodeBlog/programador-homeo…
toticavalcanti Apr 5, 2020
06f6c76
fix some merge conflicts
toticavalcanti Apr 5, 2020
b6f78f5
sync Gemfile with the controller_jobs branch
toticavalcanti Apr 5, 2020
c837c89
sync Gemfile with the controller_jobs branch
toticavalcanti Apr 5, 2020
ff6cfd5
sync merging rails_helper.rb
toticavalcanti Apr 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--require spec_helper
--format documentation
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ gem "puma", "~> 4.1"
gem "rack-cors"
gem "rails", "~> 6.0.2", ">= 6.0.2.2"
gem "redis", "~> 4.0"
gem "active_model_serializers"
gem "kaminari"

group :development, :test do
gem "byebug", platforms: %i[mri mingw x64_mingw]
Expand All @@ -28,4 +30,4 @@ group :development do
gem "spring-watcher-listen", "~> 2.0.0"
end

gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
34 changes: 28 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.10)
actionpack (>= 4.1, < 6.1)
activemodel (>= 4.1, < 6.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.2.2)
activesupport (= 6.0.2.2)
globalid (>= 0.3.6)
Expand All @@ -61,6 +66,8 @@ GEM
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.1)
case_transform (0.2)
activesupport
coderay (1.1.2)
concurrent-ruby (1.1.6)
crass (1.0.6)
Expand All @@ -79,6 +86,19 @@ GEM
i18n (1.8.2)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
jsonapi-renderer (0.2.2)
kaminari (1.2.0)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.0)
kaminari-activerecord (= 1.2.0)
kaminari-core (= 1.2.0)
kaminari-actionview (1.2.0)
actionview
kaminari-core (= 1.2.0)
kaminari-activerecord (1.2.0)
activerecord
kaminari-core (= 1.2.0)
kaminari-core (1.2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -100,7 +120,7 @@ GEM
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
parallel (1.19.1)
parser (2.7.0.5)
parser (2.7.1.0)
ast (~> 2.4.0)
pg (1.2.3)
pry (0.13.0)
Expand Down Expand Up @@ -163,14 +183,14 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.2)
rubocop (0.80.1)
rubocop (0.81.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
shoulda-matchers (4.3.0)
Expand All @@ -188,9 +208,9 @@ GEM
sprockets (>= 3.0.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.6.1)
unicode-display_width (1.7.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
Expand All @@ -200,10 +220,12 @@ PLATFORMS
ruby

DEPENDENCIES
active_model_serializers
bootsnap (>= 1.4.2)
byebug
factory_bot_rails
faker
kaminari
listen (>= 3.0.5, < 3.2)
pg (>= 0.18, < 2.0)
pry
Expand All @@ -222,4 +244,4 @@ RUBY VERSION
ruby 2.7.0p0

BUNDLED WITH
2.1.4
2.1.2
89 changes: 76 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,87 @@
# README
# Search for opportunities job for technology professionals
This project is a search engine for job opportunities for technology professionals.

This README would normally document whatever steps are necessary to get the
application up and running.
# Stack
* docker
* API: Ruby On Rails
* web client: React ou VueJs
* Chatbot: DialogFlow

Things you may want to cover:
*Search for opportunities job*

* Ruby version
> You can try here: *insert app url( [insert app url] )*.

* System dependencies
# Docker Container

* Configuration
This project was done using docker container, the container name is Nameprogramadorhomeofficeapi_app

* Database creation
## Getting Started

* Database initialization
These instructions will cover usage information and for the docker container

* How to run the test suite
### Prerequisities

* Services (job queues, cache servers, search engines, etc.)
In order to run this container you'll need docker installed.

* Deployment instructions
* [Windows](https://docs.docker.com/windows/started)
* [OS X](https://docs.docker.com/mac/started/)
* [Linux](https://docs.docker.com/linux/started/)

* ...
## Installation

clone:
```
$ git clone git@github.com:OneBitCodeBlog/programador-homeoffice-api.git
$ cd programador-homeoffice-api
```

gems install:
```
$ docker-compose run --rm app bundle install
```
RSpec install:
```
docker-compose run --rm app bundle exec rails generate rspec:install
```
generate database:
```
$ docker-compose run --rm app bundle exec rails db:create db:migrate

```
run the app:
```
$ docker-compose up --build
```
Access:
* [opportunities job here](http://0.0.0.0:3000/)

## PS. if an error like this happens
* Listening on tcp://0.0.0.0:3000
app_1 | bundler: failed to load command: puma (/gems/ruby/2.7.0/bin/puma)
app_1 | Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/pids/server.pid
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/launcher.rb:216:in `initialize'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/launcher.rb:216:in `open'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/launcher.rb:216:in `write_pid'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/launcher.rb:105:in `write_state'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/single.rb:103:in `run'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/launcher.rb:172:in `run'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/lib/puma/cli.rb:80:in `run'
app_1 | /gems/ruby/2.7.0/gems/puma-4.3.3/bin/puma:10:in `<top (required)>'
app_1 | /gems/ruby/2.7.0/bin/puma:23:in `load'
app_1 | /gems/ruby/2.7.0/bin/puma:23:in `<top (required)>'
programadorhomeofficeapi_app_1 exited with code 1

### you can try this solution:
in a shell prompt you must create tmp/pips folder in your machine with:
```
$ mkdir -p tmp/pids/
```
now run again:
```
$ docker-compose up --build
```
and now, must be working!

## License

This project is licensed under the MIT License
23 changes: 23 additions & 0 deletions app/controllers/api/v1/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module API
module V1
class JobsController < ApplicationController
def index
page = params[:page]
page_number = page.try(:[], :number)
per_page = page.try(:[], :size)

@jobs = Job.all.page(page_number).per(per_page)

render json: @jobs
end

def show
@job = Job.find(params[:id])

render json: @job
rescue ActiveRecord::RecordNotFound
head :not_found
end
end
end
end
14 changes: 14 additions & 0 deletions app/controllers/chatbot_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class ChatbotController < ApplicationController

def webhook

request.body.rewind
result = JSON.parse(request.body.read)
action = result["queryResult"]["action"]

response = InterpretService.call(action: action, result: result)

render :json => response

end
end
6 changes: 6 additions & 0 deletions app/serializers/job_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class JobSerializer < ActiveModel::Serializer
attributes :id, :title, :description, :contract,
:job_link, :salary, :company_name, :published_date

has_many :key_words
end
32 changes: 32 additions & 0 deletions app/services/create_alert_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class CreateAlertService

def initialize(session:, language:)
@session = session
@language = language
end

def call
key_word = KeyWord.find_by(tag: @language)
if key_word.nil?
KeyWord.create!(
tag: @language
)
key_word = KeyWord.last
end
Search.create!(
user: User.find_by(session_id: @session),
alarm_rate: 1,
key_word: key_word
)
response = {
"fulfillmentText": "Vagas - Remoto",
"fulfillmentMessages": {
"text": {
"text": [
"Seu alarme foi criado com sucesso. Assim que uma nova vaga para #{@language} surgir você receberá um alerta"
]
}
}
}
end
end
14 changes: 14 additions & 0 deletions app/services/create_user_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateUserService

def initialize(session:, name:)
@session = session
@name = name
end

def call
User.create!(
name: @name,
session_id: @session
)
end
end
43 changes: 43 additions & 0 deletions app/services/delete_alert_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class DeleteAlertService

def initialize(session:, tag:)
@session = session
if tag == 'todos'
@tag = nil
else
@tag = tag
end
end

def call
hashes = []
if @tag.nil?
alerts = Search.where(user: User.find_by(session_id: @session))
alerts.each do |alert|
alert.destroy
hashes << {
"card": {
"title": "Todos seus alertas foram excluídos com sucesso"
}
}
end
else
key_word = KeyWord.find_by(tag: @tag)
alerts = Search.find_by(
user: User.find_by(session_id: @session),
key_word: key_word
)
alerts.destroy
hashes << {
"card": {
"title": "Seu alerta da palavra chave #{@alert} foi excluído com sucesso"
}
}
end

response = {
"fulfillmentText": "Vagas - Remoto",
"fulfillmentMessages": hashes
}
end
end
28 changes: 28 additions & 0 deletions app/services/interpret_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class InterpretService

def self.call(action:, result:)
case action
when "search"
keyword = result["queryResult"]["parameters"]["keyword"]
SearchJobService.new(keyword: keyword).call()
when "alert"
session = result["session"].split('/')[-1]
language = result["queryResult"]["parameters"]["linguagem"]
CreateAlertService.new(session: session, language: language).call
when "list"
session = result["session"].split('/')[-1]
ListAlertService.new(session: session).call
when "delete"
session = result["session"].split('/')[-1]
tag = result["queryResult"]["parameters"]["IDAlarm"]
DeleteAlertService.new(session: session, tag: tag).call
when "input.welcome"
session = result["session"].split('/')[-1]
name = result["queryResult"]["parameters"]["name"]
CreateUserService.new(session: session, name: name).call()
else
"Desculpe, mas não te entendi. Tente novamente"
end
end

end
Loading