Skip to content

419 Add "name" filter to summary totals per cloud account API

Brad Smith requested to merge 419-filter-totals-per-clount-alt into master

#419 (closed)

This MR actually does a little cleanup refactoring before the actual intended business logic change, and in that refactoring, I made one deliberate behavior change to fix an issue in the existing implementation. The old logic for this API returned all cloud account summaries when authenticated as a superuser, but that is inconsistent with how we defined the other "dashboard" reporting API and is a potential performance landmine as we scale up our customers and number of accounts. I changed that to behave like the other API which means that by default a request as a superuser will have results limited to the superuser's own clounts; only when the optional user_id argument is added will it shift to show other users' accounts.

The refactoring was also done to simplify some redundancies in how we were handling this API's arguments. I pushed the input argument handling deeper into the stack so we could let Django Rest Framework's built-in input handling on the serializer classes do its thing. In addition to taking better advantage of DRF itself, this also makes our code better follow DRF's recommended best practices; the "interesting" logic for fetching and constructing data belongs more at the serializer level than it does at the views.

Demo: https://asciinema.org/a/192637

Edited by Brad Smith

Merge request reports

Loading