SeedPlanterOrg / seedplanter-mobile

1 stars 0 forks source link

Pull plant data from Pernual API into MongoDB collection. #12

Closed danbergeron3 closed 9 months ago

danbergeron3 commented 9 months ago

General Description

We will use the plant api to help fill our db when it runs out of documents to give to the frontend. Issue perennial only allows 100 calls a day. We can get 30 plants from one call, but to get descriptions we have to do a call for each plant.

Proposed Solution

<enter here>

Checklist


danbergeron3 commented 9 months ago

Was able to limit amount of entries we pull from db, still working to get perennial data parsed and into our db.

loki4514 commented 9 months ago

What's the issue here. i checked out the api page https://perenual.com/docs/api so you wanted to store api data into the database right?

shivy02 commented 9 months ago

@loki4514 who are u?

loki4514 commented 9 months ago

well the issue is public and it's visible to everyone so i thought i could work on that, more like open source contribution/ contribute to small project.

shivy02 commented 9 months ago

@loki4514 I appreciate your interest! I will speak with my other teammates tomorrow and get back to you. Sorry for popping the question like that lol

danbergeron3 commented 9 months ago

Yes we wanted to bring some of the data into are database, the problem was you the data we need is split across 2 collections and we only have 100 API calls. Figured out the problem just needed to pull from a different collection in the API. I was pulling from species and species details, I should have been pulling from species and plants guide. Doing the former exhausted my 100 free API calls. @loki4514

loki4514 commented 9 months ago

@danbergeron3 in one api call how many number of documents(no of records) can you retrive

  1. locally store those api call data in variable in your code.
  2. use InsertMany query to insert all locally store records.
danbergeron3 commented 9 months ago

@loki4514 requests to Species returns 30 documents for one call, which is enough for our purposes. Species documents do not contain a plant description which is a problem. So I tried using Species Details to get the description. Species Details only returns one document based of the ID. This is forcing me to make 30 API calls to match descriptions with plants. I will implement your two points in my next commit.

danbergeron3 commented 9 months ago

Also I created an object to store the data matched with its description then I was going to store that.

danbergeron3 commented 9 months ago

Was able to implement InsertMany to add db entries. Added page element to schema to allow us to keep track of where data came from.