ars get or create
This commit is contained in:
parent
3357243f7d
commit
ce69b1204c
|
|
@ -0,0 +1,31 @@
|
||||||
|
class ArsesController < ApplicationController
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
# create or update a client_artifact row
|
||||||
|
def get_or_create
|
||||||
|
name = params[:name]
|
||||||
|
provider = params[:provider]
|
||||||
|
active = params[:active]
|
||||||
|
|
||||||
|
ars = Ars.find_by_name(name)
|
||||||
|
if ars.nil?
|
||||||
|
ars = Ars.new
|
||||||
|
ars.name = name
|
||||||
|
end
|
||||||
|
|
||||||
|
ars.provider = provider
|
||||||
|
ars.active = active
|
||||||
|
ars.save
|
||||||
|
|
||||||
|
@ars = ars
|
||||||
|
unless @ars.errors.any?
|
||||||
|
@ars = Ars.find_by_name(name)
|
||||||
|
render :json => {id_int: @ars.id_int, id: @ars.id, name: @ars.name, provider: @ars.provider, active: @ars.active}, :status => :ok
|
||||||
|
else
|
||||||
|
response.status = :unprocessable_entity
|
||||||
|
respond_with @ars
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -34,6 +34,8 @@ JamAdmin::Application.routes.draw do
|
||||||
match '/jam_tracks/top/:code' => 'jam_track#dump_top_selling', :via => :get
|
match '/jam_tracks/top/:code' => 'jam_track#dump_top_selling', :via => :get
|
||||||
match '/api/jam_tracks/released' => 'jam_track#dump_released', :via => :get, as: 'released_jamtracks_csv'
|
match '/api/jam_tracks/released' => 'jam_track#dump_released', :via => :get, as: 'released_jamtracks_csv'
|
||||||
|
|
||||||
|
match '/api/arses/register' => 'arses#get_or_create', :via => :post
|
||||||
|
|
||||||
mount Resque::Server.new, :at => "/resque"
|
mount Resque::Server.new, :at => "/resque"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,16 @@ CREATE TABLE arses (
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ALTER TABLE arses DROP COLUMN ip;
|
||||||
|
ALTER TABLE arses DROP COLUMN id_int;
|
||||||
|
--ALTER TABLE arses DROP COLUMN provider;
|
||||||
|
--ALTER TABLE arses DROP COLUMN provider_instance_id;
|
||||||
|
ALTER TABLE arses ADD COLUMN provider varchar(20) NOT NULL default 'gcp';
|
||||||
|
|
||||||
|
create sequence arses_id_int_seq;
|
||||||
|
alter table arses add column id_int int not null default nextval('arses_id_int_seq');
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
ALTER TABLE generic_state ADD COLUMN top_message VARCHAR(100000);
|
ALTER TABLE generic_state ADD COLUMN top_message VARCHAR(100000);
|
||||||
Loading…
Reference in New Issue