codeforboston / jobhopper

Jobhopper helps planners and career coaches analyze patterns of career-changers to inform policy and planning decisions. Contact jobhopper@codeforboston.org if you have issues you would like to report.
MIT License
11 stars 26 forks source link

Add SOC API Endpoint #55

Closed jedpittman closed 4 years ago

jedpittman commented 4 years ago

Follow the instructions in the jobhopper readme; get the django project started and add an api endpoint for states/region; this will be used later in the mvp workflow.

GET http://localhost:/api/v1/soc-codes GET http://localhost:/api/v1/soc-codes?limit=10 {same as above, but only returns 10 codes}

This api will allow you to request the above address (whatever the django root address is when running on your machine) and to request that address and get back json like this: [{ "code" : "17-2051.00", "title" : "Civil Engineers" },{ "code" : "17-2021.00", "title" : "Agricultural Engineers"} ... ] Besides all of the codes, it should also include National: National as a pair. The output should be valid json and have a status return code of 200.

Data should come from the distinct codes in the spreadsheet added in slack by Anita Yip initially If you need to initially add it as a separate table to the postgress database that is fine. Later we'll connect this to the postgres database.

See this resource on ensuring the json returned is valid. https://jsonlint.com/

pgibb96 commented 4 years ago

I can take this one. I still am not able to assign myself to this issue, however. Should I have received an email?

pgibb96 commented 4 years ago

Data should come from the distinct codes in the spreadsheet added in slack by Anita Yip initially

I scrolled through the slack and I was not able to find the post with this data. Do you happen to know where I can find it?

pgibb96 commented 4 years ago

Also, is it best practice to create a new app for this api endpoint, or integrate it into the Jobs application (adding to views, urls, etc.)?

pgibb96 commented 4 years ago

Once I have the data, I can create a model for it. I have the rest of the steps set up. Serializer->ViewSet->URL. This was the first time I've tried creating an API endpoint in django, so I'll move this to in testing once I figure out which data I'm supposed to be using. I based it off of Sean's original API.

jedpittman commented 4 years ago

@pgibb96 yes you should have an email. If you cannot find it in your email, check your junk mail settings. For the data, I'm expecting we're going to have data in a db shortly.....I'm looking at a merge request now that should do it....standby.

jedpittman commented 4 years ago

Really the apis all in the same app. Once we get this SOC one live, we can remove the other nonsense apis we're not using. Also, we should make sure it has a path like http://:port/api/v1/soccodes or something similar. The main idea is to have api/v1 in front so that we can version the api over time if we need to.

jedpittman commented 4 years ago

Peter, I just finished working on the data tonight and unfortunately we're not ready to turn it over. So, here's some sql that you can run against the command-line prompt of your postgres database to create a fake table and a sample record to use. This api should be read only. You have some sample data to add more records if you want, but 1 should be enough to start. Hope that helps unblock you.

create table bls_oes_data_fake (area_title varchar, soc_code varchar, soc_title varchar, hourly_mean_wage decimal, annual_mean_wage decimal, total_employment bigint, soc_decimal_code varchar);

insert into bls_oes_data_fake values ('U.S.','11-0000','Management Occupations',58.88,122480.0,8054120,'11-0000.00');

select * from bls_oes_data_fake

 area_title | soc_code |                   soc_title                    | hourly_mean_wage | annual_mean_wage | total_employment | soc_decimal_code 
------------+----------+------------------------------------------------+------------------+------------------+------------------+------------------
 U.S.       | 11-0000  | Management Occupations                         |            58.88 |         122480.0 |          8054120 | 11-0000.00
 U.S.       | 13-0000  | Business and Financial Operations Occupations  |            37.56 |          78130.0 |          8183750 | 13-0000.00
 U.S.       | 15-0000  | Computer and Mathematical Occupations          |            45.08 |          93760.0 |          4552880 | 15-0000.00
 U.S.       | 17-0000  | Architecture and Engineering Occupations       |            42.69 |          88800.0 |          2592680 | 17-0000.00
 U.S.       | 19-0000  | Life, Physical, and Social Science Occupations |            37.28 |          77540.0 |          1288920 | 19-0000.00
pgibb96 commented 4 years ago

Could you try sending the email again? I just can't find it anywhere. Also, I have the API endpoint somewhat set up, but I just have a bunch of questions. What's the best way to move my branch into the in-testing phase so I can get help from more knowledgeable team-members?

pgibb96 commented 4 years ago

My main experience with web programming was a stock trading platform I made in a class with Flask, and in that project I just had a single application.py file that included the routes, the types of CRUD requests that can be made at that route, that actual logic at that route, and finally rendering a template with logic from that logic. Django definitely feels like a more efficient/professional framework, but I'm just a bit lost with stuff like serializers/viewsets/routers. I've been looking up the documentation for all of this, but it's almost so much new information that I don't really know where to begin. For example, where is the actual logic for selecting specific data. Say I want to select from that example data above all soc_code's with hourly_mean_wage above 40.00. Is that filtered at the serializer step, the viewset step, or somewhere else?

jedpittman commented 4 years ago

Hopefully this works. I tried clicking an icon next to your invite. If that doesn't work, see if you can click around on other parts of the jobhopper page. Maybe that will give you an option to accept. Some people have had success accepting that way.

I moved this ticket to in testing like you asked.

If you want to get feedback PRIOR to a formal pull request, I'd say your best bet is to commit the changes and then push to your forked repo and then just don't do the pull request. Instead ask for help in slack and provide a link to your forked repo.

Follow the information in the wiki page if you have questions: https://github.com/codeforboston/jobhopper/wiki

Of course, you can always just do the pull request and iterate with the folks helping you review. There's no penalty for iterating.

jedpittman commented 4 years ago

@pgibb96 this is merged. Some best practices for next time which I'll put on the wiki as well:

It may have been some time since you grabbed the code. When you're ready to do a pull request, grab the latest copy of the upstream code to be sure you have it and that your code works as expected afterward.

Include the output of the test run with your merge request and also include any special notes.

If you do anything in the code that doesn't seem related to the Issue at hand, please make a note of that. If there are changes we don't want/expect, then I'd be inclined to park the request -- so including a note (like about the swagger) would help reduce delays.

Have a great weekend!

jedpittman commented 4 years ago

code is merged. closing issue.

pgibb96 commented 4 years ago

@jedpittman Thanks for the advice! My plan was to do what you said and pull the most recent version to my V1.0.0 branch. Then, I would merge in just the new feature of the issue branch. However, I think I didn't correctly set up my V1.0.0 branch. I'll make sure it's all updated so you won't have to look through unnecessary commits in the future!