-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inventory groups frontend edits #4820
Inventory groups frontend edits #4820
Conversation
precommit
fix frontend tests lint
6304a41
to
8573e8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed things server side.
property = models.ForeignKey(Property, on_delete=models.CASCADE, blank=True, null=True, related_name="group_mappings") | ||
taxlot = models.ForeignKey(TaxLot, on_delete=models.CASCADE, blank=True, null=True, related_name="group_mappings") | ||
group = models.ForeignKey(InventoryGroup, on_delete=models.CASCADE, related_name="group_mappings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 💯 💯
|
||
class InventoryGroupSerializer(serializers.ModelSerializer): | ||
inventory_type = ChoiceField(choices=VIEW_LIST_INVENTORY_TYPE) | ||
member_list = serializers.SerializerMethodField() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could replace L39-40 with this
access_level_instance_data = AccessLevelInstanceSerializer(many=False, read_only=True) | |
seed/views/v3/inventory_groups.py
Outdated
data = [InventoryGroupSerializer(q).data for q in groups] | ||
group = InventoryGroup.objects.filter(organization_id=org.id, pk=pk).first() | ||
data = InventoryGroupSerializer(group).data | ||
# data = [InventoryGroupSerializer(q).data for q in group] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
seed/utils/access_level_instance.py
Outdated
from seed.models import AccessLevelInstance | ||
|
||
|
||
def access_level_filter(access_level_instance_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi, treebeard has a built in function that's very similar. you might not need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's for sure places in the code base where I should have used treebeard functions but rewrote them myself. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on this? I was attempting to remove repetition when filtering for model instances within an ali. This pattern is used all over, and could be replaced by the filter in the above code, but I didn't want to make changes to dozens of files without approval.
self.model.objects.filter(
organization_id=self.get_organization(self.request),
property__access_level_instance__lft__gte=access_level_instance.lft,
property__access_level_instance__rgt__lte=access_level_instance.rgt,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstly, the code you quoted above cannot be replaced by this function. it's missing "property__".
Secondly, if you don't need the "property__", and are just looking for the tree under an ali, .get_descendants
does that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the function would need to accept a prefix argument.
I played around with .get_descendants()
and it's not quite right. .get_descendants()
returns descendants of the node, but not the current node. So to get current and descendants, there are 4 db queries, while the original only uses 2. Let me know if you have a more elegant solution :)
access_level_instance = AccessLevelInstance.objects.get(pk=access_level_id)
current_and_descendants = AccessLevelInstance.objects.filter(id=access_level_id) | access_level_instance.get_descendants()
groups = groups.filter(access_level_instance__in=current_and_descendants)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, you're right. Maybe get_tree()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.get_tree returns the entire tree, sisters, aunts, ... everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even if you pass the current node as an arg? Its a class method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, thats perfect!
cleanup cleanup cleanup broken ali typo meters page functional
* Added inventory groups * fixed formatting * Add in AH * Groups Details page * Lint * rp edits * fix migrations * add group buttons to inv detail * groups to look like labels/dcs * least common ancestor * add all alis to group modal * move lowest common to org view * development * migration * member list default * optimize lowest_common * functional pre same node constraint * validate inventorygroup for name and org * fe error handling on group create * mapping constraint, inventory and group must share ali * precommit * overhaul of the serializer and member list * add and remove button bugs * precommit * merge conflicts * merge conflicts * Fix `hiredis` not found error (#4821) Fix hiredis not found error * navigation bugs * navigation bugs * troubleshooting * id bug * migration order precommit * lint * fix tests * integrate with develop fix frontend tests lint * fix tests, simplify migration, formatting precommit * lint * dry mapping presave * group meters page cleanup cleanup cleanup broken ali typo meters page functional * fix test --------- Co-authored-by: Elizabeth <ebeers86@gmail.com> Co-authored-by: Hannah Eslinger <heslinge@nrel.gov> Co-authored-by: Ross Perry <ross.perry@rosss-mbp-2.lan> Co-authored-by: Ross Perry <ross.perry@Rosss-MBP-2.home> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Alex Swindler <alex.swindler@nrel.gov>
* Inventory groups (#4726) * Added inventory groups * fixed formatting * Add in AH * Groups Details page * Lint * rp edits * migration * migration order precommit * lint * fix tests --------- Co-authored-by: Hannah Eslinger <heslinge@nrel.gov> Co-authored-by: Ross Perry <ross.perry@rosss-mbp-2.lan> Co-authored-by: Ross Perry <ross.perry@Rosss-MBP-2.home> * Inventory groups frontend edits (#4820) * Added inventory groups * fixed formatting * Add in AH * Groups Details page * Lint * rp edits * fix migrations * add group buttons to inv detail * groups to look like labels/dcs * least common ancestor * add all alis to group modal * move lowest common to org view * development * migration * member list default * optimize lowest_common * functional pre same node constraint * validate inventorygroup for name and org * fe error handling on group create * mapping constraint, inventory and group must share ali * precommit * overhaul of the serializer and member list * add and remove button bugs * precommit * merge conflicts * merge conflicts * Fix `hiredis` not found error (#4821) Fix hiredis not found error * navigation bugs * navigation bugs * troubleshooting * id bug * migration order precommit * lint * fix tests * integrate with develop fix frontend tests lint * fix tests, simplify migration, formatting precommit * lint * dry mapping presave * group meters page cleanup cleanup cleanup broken ali typo meters page functional * fix test --------- Co-authored-by: Elizabeth <ebeers86@gmail.com> Co-authored-by: Hannah Eslinger <heslinge@nrel.gov> Co-authored-by: Ross Perry <ross.perry@rosss-mbp-2.lan> Co-authored-by: Ross Perry <ross.perry@Rosss-MBP-2.home> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Alex Swindler <alex.swindler@nrel.gov> * Add various inventory group features (#4837) * descendant tree endpoint * refactor group merges --------- Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> * Systems and services fe edits (#4860) * Init systems and services * Add Create Service UI and API * create factories for groups and systems * system test * systems uigrids functional documentation * partial for system table * Add connection type to meters * refactor modal * building update endpoint * system endpoints * service crud functional precommit * service sad path tests error catching service tests * system sad path tests * front end error handling * Add meter import to sytems (#4857) * Fix rollup table (#4835) * default to float data type for axis data if data_type is not set on the selected column --------- Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com> * More cts fixes (#4830) Co-authored-by: Katherine Fleming <2205659+kflemin@users.noreply.github.com> * Init system meter upload * Lock sass dependency and enforce Node v20 (#4855) * use node version 20 for unittests --------- Co-authored-by: Caleb Rutan <crutan@users.noreply.github.com> Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com> Co-authored-by: Alex Swindler <Alex.Swindler@nrel.gov> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Ross Perry <perryr16@gmail.com> * fix test conflict --------- Co-authored-by: Hannah Eslinger <heslinge@nrel.gov> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Caleb Rutan <crutan@users.noreply.github.com> Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com> Co-authored-by: Alex Swindler <Alex.Swindler@nrel.gov> * Updates to meter connection modal (#4868) * Add modal to update meter connections * Create update system meter connection endpoint * modal development * hookup group meter update * Fix tests * add config to serailized meter * precommit * comments * fix test * Add dashbard endpoint * group header styling * readable keys * sort options precommit precommit * migration * precommit * fix test * hookup group meter delete --------- Co-authored-by: Hannah Eslinger <heslinge@nrel.gov> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> * Systems and services improvements (#4879) * systen service modal mods * update meter enums * property display field * alphabetical actions * nav error and modal arrangement * precommit * unit refactors * precommit * fix tests --------- Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> * Redo group meter creation (#4889) * Make create group meters modal * Remove add meter button from systems and services page * Init Group meter readings upload * Fix dupe error * Fix small things * Make little UI fixes * Add import/export to dashboard * Remove meter attched to other services from groups meter/meterreading list * Format * Format * Format * linter * translations and cleanup * lint * precommit * dismiss action * Fix meter usage * Add message to mismatched meter readings * Fix docker * styles & linter styles & linter * fix group meter usage test --------- Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com> * fix migration order * Format * precommit * add service options to modal when meter already configured * fix meter import tz issue * lint * add description text to group meters page * make-aware for meter reading query * precommit * small bugs lint * adding missing migration * precommit --------- Co-authored-by: ebeers-png <53191386+ebeers-png@users.noreply.github.com> Co-authored-by: Ross Perry <ross.perry@rosss-mbp-2.lan> Co-authored-by: Ross Perry <ross.perry@Rosss-MBP-2.home> Co-authored-by: Ross Perry <perryr16@gmail.com> Co-authored-by: Elizabeth <ebeers86@gmail.com> Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Alex Swindler <alex.swindler@nrel.gov> Co-authored-by: Caleb Rutan <crutan@users.noreply.github.com> Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com>
Any background context you want to provide?
What's this PR do?
How should this be manually tested?
Sample test files
ali_tree_better_buildings_lite.xlsx
AH_BB_250props100_lat_long.xlsx
AH_BB_250props100_lat_long_diag.xlsx - Same properties, but properties lat has been updated
What are the relevant tickets?
Screenshots (if appropriate)