|
@@ -37,7 +37,7 @@ class Person(db.Model):
|
37
|
37
|
consumptions = db.relationship("Consumption", backref="person", lazy=True)
|
38
|
38
|
|
39
|
39
|
def __repr__(self) -> str:
|
40
|
|
- return f"<Person {self.person_id}: {self.name}>"
|
|
40
|
+ return f"<Person {self.person_id}: {self.full_name}>"
|
41
|
41
|
|
42
|
42
|
@property
|
43
|
43
|
def as_dict(self) -> dict:
|
|
@@ -144,11 +144,11 @@ class Settlement(db.Model):
|
144
|
144
|
.filter_by(reversed=False)
|
145
|
145
|
.filter_by(consumption_type=c_type)
|
146
|
146
|
.group_by(Consumption.person_id)
|
147
|
|
- .order_by(Person.name)
|
|
147
|
+ .order_by(Person.full_name)
|
148
|
148
|
.outerjoin(Person)
|
149
|
149
|
.with_entities(
|
150
|
150
|
Person.person_id,
|
151
|
|
- Person.name,
|
|
151
|
+ Person.full_name,
|
152
|
152
|
func.count(Consumption.consumption_id),
|
153
|
153
|
)
|
154
|
154
|
.all()
|
|
@@ -205,7 +205,7 @@ class Consumption(db.Model):
|
205
|
205
|
reversed = db.Column(db.Boolean, default=False, nullable=False)
|
206
|
206
|
|
207
|
207
|
def __repr__(self) -> str:
|
208
|
|
- return f"<Consumption: {self.consumption_type.name} for {self.person.name}>"
|
|
208
|
+ return f"<Consumption: {self.consumption_type.name} for {self.person.full_name}>"
|
209
|
209
|
|
210
|
210
|
@property
|
211
|
211
|
def as_dict(self) -> dict:
|
|
@@ -256,8 +256,8 @@ def status() -> None:
|
256
|
256
|
@app.route("/people", methods=["GET"])
|
257
|
257
|
def get_people():
|
258
|
258
|
""" Return a list of currently known people. """
|
259
|
|
- people = Person.query.order_by(Person.name).all()
|
260
|
|
- q = Person.query.order_by(Person.name)
|
|
259
|
+ people = Person.query.order_by(Person.full_name).all()
|
|
260
|
+ q = Person.query.order_by(Person.full_name)
|
261
|
261
|
if request.args.get("active"):
|
262
|
262
|
active_status = request.args.get("active", type=int)
|
263
|
263
|
q = q.filter_by(active=active_status)
|