Changed initial_weight to be net weight, not gross weight
This commit is contained in:
@@ -190,10 +190,10 @@ class Spool(BaseModel):
|
||||
initial_weight: Optional[float] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
description=("Initial weight of the filament and spool (gross weight)"),
|
||||
description=("The initial weight, in grams, of the filament on the spool (net weight)."),
|
||||
example=1246,
|
||||
)
|
||||
empty_weight: Optional[float] = Field(
|
||||
spool_weight: Optional[float] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
description=("Weight of an empty spool (tare weight)."),
|
||||
@@ -242,9 +242,7 @@ class Spool(BaseModel):
|
||||
remaining_length: Optional[float] = None
|
||||
|
||||
if item.initial_weight is not None:
|
||||
filament_spool_weight = item.filament.spool_weight if item.filament.spool_weight is not None else 0
|
||||
spool_weight = item.empty_weight if item.empty_weight is not None else filament_spool_weight
|
||||
remaining_weight = max(item.initial_weight - spool_weight - item.used_weight, 0)
|
||||
remaining_weight = max(item.initial_weight - item.used_weight, 0)
|
||||
remaining_length = length_from_weight(
|
||||
weight=remaining_weight,
|
||||
density=filament.density,
|
||||
@@ -272,7 +270,7 @@ class Spool(BaseModel):
|
||||
filament=filament,
|
||||
price=item.price,
|
||||
initial_weight=item.initial_weight,
|
||||
empty_weight=item.empty_weight,
|
||||
spool_weight=item.spool_weight,
|
||||
used_weight=item.used_weight,
|
||||
used_length=used_length,
|
||||
remaining_weight=remaining_weight,
|
||||
|
||||
@@ -42,10 +42,10 @@ class SpoolParameters(BaseModel):
|
||||
)
|
||||
initial_weight: Optional[float] = Field(
|
||||
ge=0,
|
||||
description="The initial total weight of the filament and spool, in grams. (gross weight)",
|
||||
description="The initial weight of the filament on the spool, in grams. (net weight)",
|
||||
example=200,
|
||||
)
|
||||
empty_weight: Optional[float] = Field(
|
||||
spool_weight: Optional[float] = Field(
|
||||
ge=0,
|
||||
description="The weight of an empty spool, in grams. (tare weight)",
|
||||
example=200,
|
||||
@@ -369,7 +369,7 @@ async def create( # noqa: ANN201
|
||||
filament_id=body.filament_id,
|
||||
price=body.price,
|
||||
initial_weight=body.initial_weight,
|
||||
empty_weight=body.empty_weight,
|
||||
spool_weight=body.spool_weight,
|
||||
remaining_weight=body.remaining_weight,
|
||||
used_weight=body.used_weight,
|
||||
first_used=body.first_used,
|
||||
|
||||
Reference in New Issue
Block a user