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,
|
||||
|
||||
Reference in New Issue
Block a user