Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Issue365 add jobs #366

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
29 changes: 29 additions & 0 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,35 @@ API endpoints that Operation Code's Rails backend makes available to its React f
errors: "Some error message"
}

## Jobs | Collection [/api/v1/jobs]

## List all Jobs [GET]

+ Response 200 (application/json)

[
{
"id": 1,
"title": "A great job",
"source_url": "www.applyhere.com",
"source": "Company A",
"city": "Virginia Beach",
"state": "VA",
"country": "USA",
"description": "Our job is fun!",
"status": "active",
"remote": false,
"created_at": "2018-06-01T16:21:59.462Z",
"updated_at": "2018-06-01T16:21:59.462Z"
}
]

+ Response 422 (application/json)

{
errors: "Some error message"
}


## Location | Create [/api/v1/code_schools/:code_school_id/locations{?code_school_id,va_accepted,address1,address2,city,state,zip}]

Expand Down
36 changes: 36 additions & 0 deletions app/admin/job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ActiveAdmin.register Job do
permit_params :title, :source_url, :source, :city, :state, :country, :description, :status, :remote

index do
selectable_column
id_column

column :title
column :source_url
column :source
column :city
column :state
column :country
column :description
column :status
column :remote

actions
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pls add a form for creating/updating. Here is an example:

https://github.com/OperationCode/operationcode_backend/blob/master/app/admin/code_school.rb#L28-L45

Copy link
Collaborator Author

@leenyburger leenyburger Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I add the form and try to add a job I get the following error: "

"exception": "#<ActionView::Template::Error: To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select>",

Should I install that gem, or are we already using something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hpjaj I don't see where you responded here. If @leenyburger issue has been addressed, disregard just getting visibility.


form do |f|
f.inputs do
f.input :title
f.input :source_url
f.input :source
f.input :city
f.input :state
f.input :country
f.input :description
f.input :status
f.input :remote
end

f.actions
end
end
11 changes: 11 additions & 0 deletions app/controllers/api/v1/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Api
module V1
class JobsController < ApiController
def index
render json: Job.all, status: :ok
rescue StandardError => e
render json: { errors: e.message }, status: :unprocessable_entity
end
end
end
end
7 changes: 7 additions & 0 deletions app/models/job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Job < ApplicationRecord
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does having this in the models section of the code base make it clear enough that this is separate from Sidekiq Jobs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes. Though, it might be helpful to rename the background jobs from Job(s) to Worker(s).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you don't want JobJobs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you mention it, maybe WorkJobber.

acts_as_taggable

def self.with_tags(*args)
tagged_with(args, any: true)
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
end
resources :email_list_recipients, only: :create
resources :events, only: :index
resources :jobs, only: :index
resources :mentors, only: [:index, :create, :show]
resources :requests, only: [:index, :create, :show, :update]
resources :resources, only: [:index, :create, :show, :update, :destroy] do
Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20180531004341_create_jobs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CreateJobs < ActiveRecord::Migration[5.0]
def change
create_table :jobs do |t|
t.string :title
t.string :source_url
t.string :source
t.string :city
t.string :state
t.string :country
t.text :description
t.string :status
t.boolean :remote, default: false

t.timestamps
end
end
end
Loading