Skip to content

Instantly share code, notes, and snippets.

View lyleunderwood's full-sized avatar
💭
working

Lyle Underwood lyleunderwood

💭
working
  • ShowLabs Inc.
  • Sacramento, CA
View GitHub Profile
@lyleunderwood
lyleunderwood / Reduce.js
Last active November 22, 2017 21:48 — forked from csclyde/Reduce.js
groupsCalculated: (state) => {
const buildNetwork = (connection) => ({ service_id: connection.service_id, login_id: connection.login_id });
const connectionWithNetwork = (conn, net) => ({ ...conn, networks: [...conn.networks, buildNetwork(net)] });
const buildConnection = (conn) => ({ name: conn.name, id: conn.id, networks: [] });
return Object.values(state.all.reduce((acc, curr) => (acc[curr.name] ?
{ ...acc, [curr.name]: connectionWithNetwork(acc[curr.name], curr) } :
{ ...acc, [curr.name]: connectionWithNetwork(buildConnection(curr), curr) }
def build_address_lines(record)
lines = []
%w{store_name address1 address2 address3}.each do |field|
lines << record[field].strip unless record[field].blank?
end
last_line = ''
%w{city state zip country}.each do |field|
last_line << ' ' + record[field].strip unless record[field].blank?
end
lines << last_line unless last_line.blank?