-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata #1642
Metadata #1642
Changes from 3 commits
b03290e
2474830
0cf1c7c
50e1249
055de5d
395e0f3
2ac8d34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ | |
# enterprise edition license of COSMOS if purchased from the | ||
# copyright holder | ||
|
||
require 'cosmos/models/narrative_model' | ||
require 'cosmos/models/note_model' | ||
|
||
class NarrativeController < ApplicationController | ||
def initialize | ||
@model_class = Cosmos::NarrativeModel | ||
@model_class = Cosmos::NoteModel | ||
end | ||
|
||
def parse_time_input(x_start:, x_stop:) | ||
|
@@ -79,7 +79,7 @@ def search | |
start, stop = parse_time_input(x_start: params[:start], x_stop: params[:stop]) | ||
q = params[:q] | ||
raise NarrativeInputError "Must include q value" if q.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still Narrative There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I haven't made it up the chain yet to the controller and frontend |
||
model_array = @model_class.get(scope: params[:scope], start: start, stop: stop) | ||
model_array = @model_class.range(scope: params[:scope], start: start, stop: stop) | ||
model_array.find { |model| model.description.include? q } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is q? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment says "The string to contain in the narrative description". Worst variable name ever though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
render :json => model_array, :status => 200 | ||
rescue ArgumentError | ||
|
@@ -139,7 +139,7 @@ def show | |
render(:json => { :status => 'error', :message => e.message }, :status => 403) and return | ||
end | ||
begin | ||
model_hash = @model_class.score(score: params[:id], scope: params[:scope]) | ||
model_hash = @model_class.get(score: params[:id], scope: params[:scope]) | ||
if model_hash.nil? | ||
render :json => { :status => 'error', :message => 'not found' }, :status => 404 | ||
return | ||
|
@@ -238,7 +238,7 @@ def update | |
render(:json => { :status => 'error', :message => e.message }, :status => 403) and return | ||
end | ||
begin | ||
hash = @model_class.score(score: params[:id], scope: params[:scope]) | ||
hash = @model_class.get(score: params[:id], scope: params[:scope]) | ||
if hash.nil? | ||
render :json => { :status => 'error', :message => 'not found' }, :status => 404 | ||
return | ||
|
@@ -295,19 +295,17 @@ def delete | |
render(:json => { :status => 'error', :message => e.message }, :status => 403) and return | ||
end | ||
begin | ||
hash = @model_class.score(score: params[:id], scope: params[:scope]) | ||
if hash.nil? | ||
count = @model_class.destroy(start: params[:id], scope: params[:scope]) | ||
if count == 0 | ||
render :json => { :status => 'error', :message => 'not found' }, :status => 404 | ||
return | ||
end | ||
model = @model_class.from_json(hash.symbolize_keys, scope: params[:scope]) | ||
model.destroy() | ||
Cosmos::Logger.info( | ||
"Narrative destroyed: #{model}", | ||
scope: params[:scope], | ||
user: user_info(request.headers['HTTP_AUTHORIZATION']) | ||
) | ||
render :json => { "status" => 1 }, :status => 204 | ||
render :json => { "status" => count }, :status => 204 | ||
rescue Cosmos::NarrativeError => e | ||
render :json => { :status => 'error', :message => e.message, :type => e.class }, :status => 400 | ||
rescue StandardError => e | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? Why does it default to +/- 7 days?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know but I didn't change it. It doesn't match the comment either which says start is minus 12 hrs and end is plus 2 days. I'm honestly not sure when the search feature is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed