Skip to content
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

Coding Challenge #14

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Coding Challenge #14

wants to merge 12 commits into from

Conversation

pyreta
Copy link

@pyreta pyreta commented Aug 26, 2016

No description provided.

## Instructions
- bundle install
- npm install
- bundle exec rake db:reset to re-seed database
Copy link
Contributor

Choose a reason for hiding this comment

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

@pyreta the only diff in this PR should be new files you add to write the web server/web application; probably don't want to overwrite this README

Copy link
Author

Choose a reason for hiding this comment

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

@mecampbellsoup Had an error pushing with the existing license and README, so I removed it.

@@ -0,0 +1,20 @@
const AppDispatcher = require("../dispatcher/dispatcher");
Copy link

Choose a reason for hiding this comment

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

I believe there's a way to set another lookup path in your webpack config so that you don't have to use relative paths in your require statements

In other words, instead of require('../dispatcher/dispatcher'), you could require('dispatcher/dispatcher')

Require also looks for dispatcher/index.js and dispatcher/package.json if it doesn't find dispatcher.js right away, so your require statement could just become require('dispatcher') if you rename dispatcher.js to index.js

Copy link
Author

Choose a reason for hiding this comment

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

@danielchangNYC Ah this is a great call Daniel. I believe I could useresolve.moduleDirectoriesthe way I resolved the extensions.

Copy link

Choose a reason for hiding this comment

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

Even better, this webpack contributor recommends using resolve.root

Copy link
Author

Choose a reason for hiding this comment

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

@danielchangNYC Thanks for this tip! I updated the webpack config to resolve.root and removed all those ugly "../"'s. I also changed dispatcher.js to index.js to see if it defaulted to that file (which it did). This is definitely something I will use moving forward. Thanks again!

class CreateBanks < ActiveRecord::Migration
def change
create_table :banks do |t|
t.integer :routing_num, null:false
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a string not integer probably.

Copy link
Author

Choose a reason for hiding this comment

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

@mecampbellsoup This is corrected in a later migration.

@mecampbellsoup
Copy link
Contributor

@pyreta I'd like you to work on an enhancement before we have any sort of phone call. Here goes:

  • Add a script or rake task (e.g. something akin to rake db:seed in Rails land) which goes to the URL containing the list of banks, parses it, and either stores those records in memory or writes them to the application's database. This way anyone can clone this repo, run your rake task, and use the application (i.e. after the rake task any requests for a specific bank should serve the bank's data as JSON)

@@ -0,0 +1,45 @@
require 'http'

Copy link
Contributor

Choose a reason for hiding this comment

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

@pyreta nice work, you got the fixed width thing.

Overall comments: would love to see some specs for the behavior contained in this file. It would probably be easier to write those tests if you encapsulated the logic in seeds.rb into a class or classes.

So in seeds.rb you can just do something like BankDataParser.perform!, and the you'll have the actual (unit-tested) logic in lib/<your-app-name>/bank_data_parser.rb.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also would be nice to see a separation of concerns, where the concerns of seeds.rb at the moment is twofold: fetching the data, parsing it by row/entry in the sheet, and persisting those records to the database. The last two can probably be combined into a single concern, but the former (fetching) should standalone.

  • lib/<app-name>/actions/fetch_bank_data.rb
  • lib/<app-name>/actions/parse_bank_data.rb

You can name them whatever you want though just providing an example.

@pyreta
Copy link
Author

pyreta commented Aug 29, 2016

@mecampbellsoup just runrake db:seed and the database should be populated with data that is fetched and parsed. You may need to run rake db:create first, and bundle install. See seeds.rb.

json.extract! @bank, :zipcode, :zipcode_ext
json.street_address @bank.address
end
json.last_change_date @bank.last_change_date.to_s[0...10]
Copy link

Choose a reason for hiding this comment

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

Since this is the view layer, I might opt for creating a more direct interface for the bank object instead of manipulating data here.

:data_view_code,
:office_code,
:last_change_date,
:inst_status__code
Copy link

Choose a reason for hiding this comment

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

Much cleaner!

@mecampbellsoup
Copy link
Contributor

@pyreta how's the 'fetch, parse and store' rake task functionality coming along?

Also, can you make this deployable to Heroku? Feel free to ask questions of us in this PR.

@pyreta
Copy link
Author

pyreta commented Aug 31, 2016

@mecampbellsoup Are you referring to the changes I made in the seed file? I divided the functionality of the fetching and parsing into separate classes (which tests are written for in the spec folder). The seed file uses these classes when you run rake db:seed. See seeds.rb. Is there something else I'm missing?
Yes I could make this deployable to Heroku.

@pyreta
Copy link
Author

pyreta commented Aug 31, 2016

@mecampbellsoup Should be Deployable on Heroku now...

@mecampbellsoup
Copy link
Contributor

@pyreta sorry I meant deployed, ha. Once deployed just tell us the public URL.

@pyreta
Copy link
Author

pyreta commented Aug 31, 2016

@mecampbellsoup
Copy link
Contributor

@pyreta
Copy link
Author

pyreta commented Aug 31, 2016

@mecampbellsoup As of right now there is no error handling for invalid routing numbers.

@pyreta
Copy link
Author

pyreta commented Sep 1, 2016

@mecampbellsoup Added some error handling to account for invalid routing numbers. Should be all good now.

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.

3 participants