Remove YAGNI stuff from corpus controller

pull/830/head
Rick Carlino 2018-05-04 10:42:51 -05:00
parent b23c9a97a5
commit 34a39f38fc
6 changed files with 7 additions and 25 deletions

View File

@ -1,22 +1,15 @@
module Api
# A "corpus" is a dictionary of celery script nodes and arg types.
# The corpus helps ceery script users know the correct format of CS nodes.
# My original intention was to support multiple corpuses based on use case.
# In retrospec, that was a case of YAGNI. TODO: Remove `#index` action.
# The corpus helps celery script users know the correct format of CS nodes.
class CorpusesController < Api::AbstractController
skip_before_action :check_fbos_version, only: [:index, :show]
skip_before_action :authenticate_user!, only: [:index, :show]
THE_ONLY_CORPUS_FOR_NOW = Sequence::Corpus.as_json({})
CORPUS = Sequence::Corpus.as_json({})
# GET /api/corpuses
def index
render json: [THE_ONLY_CORPUS_FOR_NOW]
end
# GET /api/corpuses/:id
def show
render json: THE_ONLY_CORPUS_FOR_NOW
render json: CORPUS
end
end
end

View File

@ -1,4 +1,4 @@
# Regimens are an order checklist of "TODO" items for a bot, spread out at
# Regimens are an ordered checklist of "TODO" items for a bot, spread out at
# specified times after a start date.
# Examples: Water cabbage 3 times a day for 40 days, then twice a day for 20
# days after that.

View File

@ -2,7 +2,6 @@ FarmBot::Application.routes.draw do
namespace :api, defaults: {format: :json}, constraints: { format: "json" } do
# Standard API Resources:
{
corpuses: [:index, :show],
farm_events: [:create, :destroy, :index, :update],
farmware_installations: [:create, :destroy, :index],
images: [:create, :destroy, :index, :show],
@ -28,6 +27,7 @@ FarmBot::Application.routes.draw do
tokens: [:create, :show],
web_app_config: [:destroy, :show, :update],
}.to_a.map{|(name, only)| resource name, only: only}
get "/corpus" => "corpuses#show", as: :api_corpus
resources(:points, except: []) { post :search, on: :collection }

View File

@ -5,16 +5,8 @@ describe Api::CorpusesController do
describe '#show' do
it 'renders one corpus' do
get :show, params: {id: 123}
get :show
expect(json.keys).to eq([:tag, :args, :nodes])
end
end
describe "#index" do
it 'renders all corpuses' do
get :index
expect(json.length).to eq(1)
expect(json.first.keys).to eq([:tag, :args, :nodes])
end
end
end

View File

@ -14,7 +14,6 @@ export type GetState = () => Everything;
/** A Redux Thunk function. */
export interface Thunk {
// TODO: CONVERT THIS TO A GENERIC (Thunk<T>)
// tslint:disable-next-line:no-any
(dispatch: Function, getState: GetState): any;
}

View File

@ -25,7 +25,5 @@ export function rootReducer(
action: ReduxAction<{}>) {
(action.type === Actions.LOGOUT) && Session.clear();
// TODO: Get rid of this nasty type cast / hack. Resulted from TSC 2.4 upgrade
// - RC 30 JUN 17
return reducers(state, action) as Everything;
return reducers(state, action);
}