hackgvl / trolley-tracker-api-dot-net

API for tracking Greenville's trolleys with .NET
MIT License
4 stars 6 forks source link

Preventing the number of database calls from scaling with the number of users/roles #30

Closed micahlee closed 7 years ago

micahlee commented 7 years ago

This is to begin resolving #29.

I updated the way the queries are structured in GetRolesForUser, GetUsersInRole, and FindUsersInRole to make the number of db queries constant, rather than growing with the number of users and roles involved. I also added a couple of additional unit tests to verify this.

There's probably more that can be done here. Particularly the Add and Remove methods will scale even more poorly since there is so much getting queried in the tight loop, but I'm guessing these don't get called enough to cause an issue.

bikeoid commented 7 years ago

This looks great and thanks for adding the tests. On my machine, I had to copy the connection strings from web.config to app.config for it to work. What is the best way to reference the connection strings from the Unit Test?

micahlee commented 7 years ago

@bikeoid Yeah, it looks like it was just defaulting to a LocalDB instance on my machine when running the unit tests without a connection string set in the app.config. Copying the connection strings to match the web app is probably the right solution for pointing it to the actual DB.