API Reference
Gear components sub-module.
Provides CRUD operations, schemas, and models for gear component tracking (e.g., chains, tires, pedals, strings).
Exports
- CRUD: get_gear_component_by_id, get_gear_components_user, get_gear_components_user_by_gear_id, create_gear_component, edit_gear_component, delete_gear_component
- Schemas: GearComponentBase, GearComponentCreate, GearComponentRead, GearComponentUpdate, GearComponentTypesRead
- Models: GearComponents (ORM model)
GearComponentBase
Bases: BaseModel
Base model for gear component data.
Attributes:
| Name | Type | Description |
|---|---|---|
gear_id |
StrictInt
|
Foreign key to gear table. |
type |
StrictStr
|
Type of gear component. |
brand |
StrictStr
|
Gear component brand. |
model |
StrictStr
|
Gear component model name. |
purchase_date |
datetime | None
|
Purchase date. |
retired_date |
datetime | None
|
Retired date. |
active |
StrictBool | None
|
Whether component is active. |
expected_kms |
StrictInt | None
|
Expected kilometers. |
purchase_value |
StrictFloat | None
|
Purchase value. |
Source code in backend/app/gears/gear_components/schema.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
GearComponentCreate
Bases: GearComponentBase
Schema for creating a gear component.
Source code in backend/app/gears/gear_components/schema.py
169 170 | |
GearComponentRead
Bases: GearComponentBase
Schema for reading a gear component.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
StrictInt
|
Unique identifier. |
user_id |
StrictInt
|
Foreign key to user. |
current_distance |
StrictFloat
|
Accumulated distance. |
current_time |
StrictFloat
|
Accumulated time. |
Source code in backend/app/gears/gear_components/schema.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
GearComponentTypesRead
Bases: BaseModel
Schema for reading component type lists.
Attributes:
| Name | Type | Description |
|---|---|---|
bike |
list[str]
|
Valid bike component types. |
shoes |
list[str]
|
Valid shoes component types. |
racquet |
list[str]
|
Valid racquet component types. |
windsurf |
list[str]
|
Valid windsurf component types. |
Source code in backend/app/gears/gear_components/schema.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
GearComponentUpdate
Bases: GearComponentBase
Schema for updating a gear component.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
StrictInt
|
Unique identifier. |
Source code in backend/app/gears/gear_components/schema.py
210 211 212 213 214 215 216 217 218 219 220 221 | |
GearComponents
Bases: Base
Gear component data model.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Mapped[int]
|
Primary key. |
user_id |
Mapped[int]
|
Foreign key to users table. |
gear_id |
Mapped[int]
|
Foreign key to gear table. |
type |
Mapped[str]
|
Type of gear component. |
brand |
Mapped[str]
|
Gear component brand. |
model |
Mapped[str]
|
Gear component model. |
purchase_date |
Mapped[datetime]
|
Purchase date. |
retired_date |
Mapped[datetime | None]
|
Retired date. |
active |
Mapped[bool]
|
Whether component is active. |
expected_kms |
Mapped[int | None]
|
Expected kilometers. |
purchase_value |
Mapped[Decimal | None]
|
Purchase value. |
users |
Mapped[Users]
|
Relationship to Users model. |
gear |
Mapped[Gear]
|
Relationship to Gear model. |
Source code in backend/app/gears/gear_components/models.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
create_gear_component
create_gear_component(gear_component, user_id, db)
Create a new gear component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gear_component
|
GearComponentCreate
|
Create schema data. |
required |
user_id
|
int
|
Authenticated user ID (token). |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
GearComponents
|
Created ORM gear component. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
On database error (500). |
Source code in backend/app/gears/gear_components/crud.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
delete_gear_component
delete_gear_component(user_id, gear_component_id, db)
Delete a gear component by user and ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Owner user ID. |
required |
gear_component_id
|
int
|
Component ID to delete. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If not found (404) or database error (500). |
Source code in backend/app/gears/gear_components/crud.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
edit_gear_component
edit_gear_component(gear_component, db)
Edit an existing gear component by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gear_component
|
GearComponentUpdate
|
Update schema data. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
GearComponents
|
Updated ORM gear component. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If not found (404) or database error (500). |
Source code in backend/app/gears/gear_components/crud.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_gear_component_by_id
get_gear_component_by_id(gear_component_id, db)
Retrieve a gear component by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gear_component_id
|
int
|
Primary key. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
GearComponents | None
|
ORM gear component or None. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
On database error (500). |
Source code in backend/app/gears/gear_components/crud.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
get_gear_components_user
get_gear_components_user(user_id, db)
Retrieve all gear components for a user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Owner user ID. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
list[GearComponents]
|
List of ORM gear components. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
On database error (500). |
Source code in backend/app/gears/gear_components/crud.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_gear_components_user_by_gear_id
get_gear_components_user_by_gear_id(user_id, gear_id, db, active=None)
Retrieve gear components by user and gear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Owner user ID. |
required |
gear_id
|
int
|
Gear ID to filter by. |
required |
db
|
Session
|
Database session. |
required |
active
|
bool | None
|
Optional active-status filter. |
None
|
Returns:
| Type | Description |
|---|---|
list[GearComponents]
|
List of ORM gear components. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
On database error (500). |
Source code in backend/app/gears/gear_components/crud.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |