Post on 31-May-2020
Welp…
By: James SaporitoCorinne Dmitruk
Platforms We Used
Bootstrap - client side styling
AngularJS - client side responsive
ASP.NET - server side implementation (because selling your soul to Microsoft is
fun)
Yelp API - to get pictures from their database (these are not included in the
datasets they give as a download)
MongoDB - for the database to hold the Yelp JSON data
Challenges We Faced
Yelp’s Academic Challenge datasets have a large amount of information
Originally the idea was just to open the json files given to us through C# and query with Linq to
Json.
This worked for samples of the dataset but not the whole thing, when opening the file in C# there
would be an “Out of Memory Exception”
The reviews json file was too big to be opened in Notepad++ (it’s (close to) 4GB)
Solution: switched to MongoDB since it meant to solve this problem
MongoDB
Easier than expected to set up
Easy as…
1 2
3
J(a)SON This is why we don’t let Corinne make PowerPoints
3.22 GB takes a looooooooong time………..
*Insert Excitement*
[ ,
,
,
Calling MongoDB From ASP.NET
A query through ASP.NET looks something like:.....
var filter = new BsonDocument("categories", new BsonDocument("$eq", "Food"));
var busFoodResult = business.Find(filter).Sort("{stars: -1}").Limit(50).ToList();
BsonDocument is basically making another Json object
Filter is looking for a record in the database where under categories, food is part of the list.
Sorting by the amount of stars. If we would have used a 1 it would be ascending, we used -1 which is
descending
We are limiting the amount of records returning to the server, too much data would make it slow.
You can also use linq to query MongoDb, if you really wanted to
AngularJS
To start you need to declare an app and there you can configure routing
Declare dependencies
ngRoute is required to
actually do the routingThis is the
default
Any other routes
come after the
default
If the route can’t be found
this is how it knows
where to go
AngularJS
Super simple method calling the server looks like:
Using the Yelp API
● Data set didn’t include photos
● EXAMPLE: “GET https://api.yelp.com/v3/businesses/{id goes here}”
● Yelp token in the header
● Returns information in JSON
● Extract the “image_url” from the JSON and insert it into the HTML
Future Work
Pagination for the table
So instead of just limiting to 50, each page can be 50 and can jump through all of the records
Increase performance
Pages could load faster
...I wanna know…Can you show me?....
Where to get the Driver for MongoDB to use in ASP.NET: https://docs.mongodb.com/ecosystem/drivers/csharp/
Wanna query MongoDB with ASP.NET? Go here!:
https://www.codementor.io/pmbanugo/working-with-mongodb-in-net-1-basics-g4frivcvz
Need to know how to import the data in the first place? https://docs.mongodb.com/getting-started/shell/import-data/
Oh, right, don’t you need to get the data before you import it? https://www.yelp.com/dataset_challenge
(Disney reference)