-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create buildings table * Set up buildings table to have prexisting building * Create script * Change building_id to building * move script to seeding dir * Update backend/app/services/implementations/log_records_service.py Co-authored-by: Safwaan Chowdhury <57375371+Safewaan@users.noreply.github.com> * Add JOIN statement * fix features to use building_id instead of building * format * chnage building to building id * fix csv * address PR comments * add default buildings on db creation * pr comments * final touchups * final touchups * remove redundant date check * run linter there's so many changes * add building filters when counting log records --------- Co-authored-by: Safewaan <Safewaan@users.noreply.github.com> Co-authored-by: Safwaan Chowdhury <57375371+Safewaan@users.noreply.github.com> Co-authored-by: Kelly Pham <phamkelly17@gmail.com> Co-authored-by: Connor Bechthold <connorbechthold@icloud.com>
- Loading branch information
1 parent
4905d93
commit 211dc99
Showing
41 changed files
with
460 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from . import db | ||
from sqlalchemy import inspect, cast, String | ||
from sqlalchemy.orm.properties import ColumnProperty | ||
|
||
|
||
class Buildings(db.Model): | ||
__tablename__ = "buildings" | ||
id = db.Column(db.Integer, primary_key=True, nullable=False) | ||
address = db.Column(db.String, nullable=False) | ||
name = db.Column(db.String, nullable=False) | ||
log_record = db.relationship("LogRecords", back_populates="building") | ||
resident = db.relationship("Residents", back_populates="building") | ||
|
||
def to_dict(self, include_relationships=False): | ||
# define the entities table | ||
cls = type(self) | ||
|
||
mapper = inspect(cls) | ||
formatted = {} | ||
for column in mapper.attrs: | ||
field = column.key | ||
attr = getattr(self, field) | ||
# if it's a regular column, extract the value | ||
if isinstance(column, ColumnProperty): | ||
formatted[field] = attr | ||
# otherwise, it's a relationship field | ||
# (currently not applicable, but may be useful for entity groups) | ||
elif include_relationships: | ||
# recursively format the relationship | ||
# don't format the relationship's relationships | ||
formatted[field] = [obj.to_dict() for obj in attr] | ||
return formatted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.