Skip to content

Allocadia#72

Open
bennettgo wants to merge 4 commits intomasterfrom
allocadia-oem
Open

Allocadia#72
bennettgo wants to merge 4 commits intomasterfrom
allocadia-oem

Conversation

@bennettgo
Copy link
Contributor

A branch for us to review the Allocadia custom connector built for OEM efforts

A branch for us to review the Allocadia custom connector built for OEM efforts
@bennettgo bennettgo self-assigned this Jul 15, 2019
},
]
end
},

Choose a reason for hiding this comment

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

Layout/IndentHash: Indent the right brace the same as the start of the line where the left brace is.

parse_output: 'date_time_conversion',
type: 'date_time',
name: 'updatedDate'
},

Choose a reason for hiding this comment

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

Style/TrailingCommaInArrayLiteral: Avoid comma after the last item of an array.

},

budget: {
fields: lambda do |_connection, _config_fields|

Choose a reason for hiding this comment

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

Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
Metrics/BlockLength: Block has too many lines. [65/25]

end
},

budget: {

Choose a reason for hiding this comment

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

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

title: 'Allocadia',

methods: {
make_schema_builder_fields_sticky: lambda do |input|
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is for Custom action! I think this was added to the connector that we built for initial demo.
Don't we need Custom action for Allocadia?

cells&.each do |id,cell|
col = columns[id]

unless col == nil || cell['value'] == nil || cell['value'] == ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using - .blank? or .present? instead

choiceName = col['choices'].select {|choice| choice['id'] == id}[0]['label']
msStr = msStr + choiceName + "::" + pcnt + ","
end
value = msStr[0...-1] # trims the trailing , from the end
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using - value.join(',') - so we can avoid trimming the trailing ,

col = input[:column]
value = input[:value]

value = (value == "") ? nil : value # treat empty string the same as nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using - .presence

unless value == nil
case col['type']
when 'DROPDOWN'
value = col['choices'].select {|choice| choice['label'] == value}[0]['id']
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using - .dig(..) for retrieving values of 2 or more level deep in nested objects

Choose a reason for hiding this comment

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

I tried to replace with col['choices'].select {|choice| choice['label'] == value}.dig(0,:id) but got an internal error when I ran that. Am I missing something?

Copy link
Contributor

@sharat-developer sharat-developer Jul 26, 2019

Choose a reason for hiding this comment

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

Can you try .dig(0, 'id') instead of .dig(0,:id)?

Choose a reason for hiding this comment

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

Thanks, that works.

itemfilter = input['filter'] ? "?$filter=#{input['filter']}" : ""
#columns = call(:get_line_item_columns_key_id, { budgetId: input['budgetId'] })

budget_items = get("/v1/lineitems/#{itemfilter}").after_response do |code, body, headers|
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as line #834!

location = headers['location']
job_id = location&.split('/')[-1]
job = get("/v1/jobs/lineitems/#{job_id}")
error(job)
Copy link
Contributor

Choose a reason for hiding this comment

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

This action will result in an error and will not continue unless it's wrapped in a conditional block!

},

pick_lists: {
foldersbudgets: ->(_connection) { get('/v1/budgets')&.pluck('name', 'id') || [] },
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as line #834!


pick_lists: {
foldersbudgets: ->(_connection) { get('/v1/budgets')&.pluck('name', 'id') || [] },
budgets: ->(_connection) { get('/v1/budgets?$filter=folder eq false')&.pluck('name', 'id') || [] },
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as line #834!

pick_lists: {
foldersbudgets: ->(_connection) { get('/v1/budgets')&.pluck('name', 'id') || [] },
budgets: ->(_connection) { get('/v1/budgets?$filter=folder eq false')&.pluck('name', 'id') || [] },
folders: ->(_connection) { get('/v1/budgets?$filter=folder eq true')&.pluck('name', 'id') || [] },
Copy link
Contributor

Choose a reason for hiding this comment

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

Same feedback as line #834!

@bennettgo bennettgo changed the title First commit Allocadia Aug 2, 2019
["GRID","GRID"],
["OTHER","OTHER"],
["PO","PO"],
["ROLLUP","ROLLUP"]

Choose a reason for hiding this comment

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

Style/WordArray: Use %w or %W for an array of words.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceAfterComma: Space missing after comma.

["DETAILS","DETAILS"],
["GRID","GRID"],
["OTHER","OTHER"],
["PO","PO"],

Choose a reason for hiding this comment

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

Style/WordArray: Use %w or %W for an array of words.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceAfterComma: Space missing after comma.

["BUDGET","BUDGET"],
["DETAILS","DETAILS"],
["GRID","GRID"],
["OTHER","OTHER"],

Choose a reason for hiding this comment

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

Style/WordArray: Use %w or %W for an array of words.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceAfterComma: Space missing after comma.

["ACTUAL","ACTUAL"],
["BUDGET","BUDGET"],
["DETAILS","DETAILS"],
["GRID","GRID"],

Choose a reason for hiding this comment

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

Style/WordArray: Use %w or %W for an array of words.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceAfterComma: Space missing after comma.

[
["ACTUAL","ACTUAL"],
["BUDGET","BUDGET"],
["DETAILS","DETAILS"],

Choose a reason for hiding this comment

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

Style/WordArray: Use %w or %W for an array of words.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceAfterComma: Space missing after comma.


output_fields: lambda do |object_definitions|
object_definitions['line_item'].only('itemId')
end,

Choose a reason for hiding this comment

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

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.

}],

input_fields: lambda do |object_definitions|
object_definitions['line_item'].only('name','type','parentId','cells').required('name','type')

Choose a reason for hiding this comment

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

Layout/SpaceAfterComma: Space missing after comma.
Metrics/LineLength: Line is too long. [102/80]

inject(:merge)

post("/v1/budgets/#{input.delete('updateBudgetId')}/lineitems", input.compact)
.after_response do |code, body, headers|

Choose a reason for hiding this comment

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

Layout/MultilineMethodCallIndentation: Use 2 (not 1) spaces for indenting an expression spanning multiple lines.

map { |key, value| { columns[key]['id'] => { 'value' => call(:format_cell_to_allocadia, { value: value, column: columns[key] } ) } } }&.
inject(:merge)

post("/v1/budgets/#{input.delete('updateBudgetId')}/lineitems", input.compact)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [86/80]


input['cells'] = input['cells']&.
compact&.
map { |key, value| { columns[key]['id'] => { 'value' => call(:format_cell_to_allocadia, { value: value, column: columns[key] } ) } } }&.

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [146/80]
Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Layout/SpaceInsideParens: Space inside parentheses detected.

%w(GRID GRID),
%w(OTHER OTHER),
%w(PO PO),
%w(ROLLUP ROLLUP)

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].

%w(DETAILS DETAILS),
%w(GRID GRID),
%w(OTHER OTHER),
%w(PO PO),

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].

%w(BUDGET BUDGET),
%w(DETAILS DETAILS),
%w(GRID GRID),
%w(OTHER OTHER),

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].

%w(ACTUAL ACTUAL),
%w(BUDGET BUDGET),
%w(DETAILS DETAILS),
%w(GRID GRID),

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].

[
%w(ACTUAL ACTUAL),
%w(BUDGET BUDGET),
%w(DETAILS DETAILS),

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].


pick_lists: {
foldersbudgets: ->(_connection) { get('/v1/budgets')&.
pluck('name', 'id') || [] },

Choose a reason for hiding this comment

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

Layout/BlockEndNewline: Expression at 1206, 67 should be on its own line.

},

pick_lists: {
foldersbudgets: ->(_connection) { get('/v1/budgets')&.

Choose a reason for hiding this comment

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

Style/Lambda: Use the lambda method for multiline lambdas.
Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.

inject(:merge)

post("/v1/budgets/#{input.delete('updateBudgetId')}/lineitems",
input.compact)

Choose a reason for hiding this comment

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

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.

call(:format_cell_to_allocadia,
value: value, column: columns[key])
}
}

Choose a reason for hiding this comment

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

Layout/MultilineHashBraceLayout: Closing hash brace must be on the same line as the last hash element when opening brace is on the same line as the first hash element.

{ 'value' =>
call(:format_cell_to_allocadia,
value: value, column: columns[key])
}

Choose a reason for hiding this comment

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

Layout/MultilineHashBraceLayout: Closing hash brace must be on the same line as the last hash element when opening brace is on the same line as the first hash element.

end,

folders: lambda do |_connection|
get('/v1/budgets?$filter=folder eq true')&.pluck('name', 'id') || []

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.

end,

budgets: lambda do |_connection|
get('/v1/budgets?$filter=folder eq false')&.pluck('name', 'id') || []

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.


pick_lists: {
foldersbudgets: lambda do |_connection|
get('/v1/budgets')&.pluck('name', 'id') || []

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.

{ 'value' =>
call(:format_cell_to_allocadia,
value: value, column: columns[key])
}

Choose a reason for hiding this comment

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

Layout/MultilineHashBraceLayout: Closing hash brace must be on the same line as the last hash element when opening brace is on the same line as the first hash element.

{ columns[key]['id'] =>
{ 'value' =>
call(:format_cell_to_allocadia,
value: value, column: columns[key])

Choose a reason for hiding this comment

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

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.

columns = call(:get_line_item_columns_key_name, { budgetId: input.delete('updateBudgetId') })

# handle case where it could be a cells object coming in as a string
if (input['cells']&.is_a?(String))

Choose a reason for hiding this comment

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

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.

"</span> in <span class='provider'>Allocadia</span>",

execute: lambda do |_connection, input|
columns = call(:get_line_item_columns_key_name, { budgetId: input.delete('updateBudgetId') })

Choose a reason for hiding this comment

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

Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Metrics/LineLength: Line is too long. [101/80]

of: 'object',
properties: object_definitions['line_item']
}]
end,

Choose a reason for hiding this comment

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

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.

unless item['parentId'] == nil # filter out grand total row
item['itemId'] = item.delete 'id'
item.delete '_links'
# item['cells'] = call(:format_item_cells, { columns: columns, cells: item['cells'] })

Choose a reason for hiding this comment

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

Layout/CommentIndentation: Incorrect indentation detected (column 1 instead of 14).
Metrics/LineLength: Line is too long. [99/80]

all_items = []

budget_items.each do |item|
unless item['parentId'] == nil # filter out grand total row

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Style/Next: Use next to skip iteration.
Style/NilComparison: Prefer the use of the nil? predicate.

Copy link
Contributor

@sharat-developer sharat-developer left a comment

Choose a reason for hiding this comment

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

V.Important:

Important:

columns = call(:get_line_item_columns_raw, { budgetId: item['budgetId'] })

if input['primaryExternalColumnName']
primaryColId = columns.select {|col| col['name'] == input['primaryExternalColumnName'] }[0]['id']
Copy link
Contributor

Choose a reason for hiding this comment

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

if (item['cells'][primaryColId])
choiceId = item['cells'][primaryColId]['value']
choice = choices.select {|ch| ch['id'] == choiceId }[0]
externalId = choice['externalAssociations'].size > 0 ? choice['externalAssociations'][0]['externalId'] : nil
Copy link
Contributor

Choose a reason for hiding this comment

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

columns = call(:get_line_item_columns_raw, { budgetId: item['budgetId'] })

if input['primaryExternalColumnName']
primaryColId = columns.select {|col| col['name'] == input['primaryExternalColumnName'] }[0]['id']
Copy link
Contributor

Choose a reason for hiding this comment

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

primaryColId = columns.select {|col| col['name'] == input['primaryExternalColumnName'] }[0]['id']
choices = get("/v1/budgets/#{item['budgetId']}/columns/#{primaryColId}/choices")
if (item['cells'][primaryColId])
choiceId = item['cells'][primaryColId]['value']
Copy link
Contributor

Choose a reason for hiding this comment

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

if (item['cells'][primaryColId])
choiceId = item['cells'][primaryColId]['value']
choice = choices.select {|ch| ch['id'] == choiceId }[0]
externalId = choice['externalAssociations'].size > 0 ? choice['externalAssociations'][0]['externalId'] : nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants