Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -274,13 +274,19 @@ def perform_seeding(db: Session):
|
|
| 274 |
# Use deterministic UUID based on asset_id so links don't break on restart
|
| 275 |
uid = str(uuid.uuid5(namespace, a["id"]))
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
new_asset = Asset(
|
| 278 |
id=uid, owner_id=owner, project_name=a["name"],
|
| 279 |
asset_id=a["id"], location=f"Lab Bay {random.randint(1, 20)}", capacity=100.0,
|
| 280 |
bms_provider="ZenVolt Native", category=json.dumps(["Grid-Scale"]),
|
| 281 |
project_stage=a["stage"], health_score=a["health"],
|
| 282 |
remaining_life=round(a["health"]/20, 1), degradation_rate=2.1,
|
| 283 |
-
confidence=0.94, is_online=1, created_at=datetime.utcnow()
|
|
|
|
|
|
|
| 284 |
)
|
| 285 |
db.add(new_asset)
|
| 286 |
|
|
|
|
| 274 |
# Use deterministic UUID based on asset_id so links don't break on restart
|
| 275 |
uid = str(uuid.uuid5(namespace, a["id"]))
|
| 276 |
|
| 277 |
+
# Add dummy blockchain data for "Certified" assets
|
| 278 |
+
nft_hash = f"0x{uuid.uuid4().hex}" if a["stage"] == "Certified" else None
|
| 279 |
+
explorer_url = f"https://etherscan.io/tx/{nft_hash}" if nft_hash else None
|
| 280 |
+
|
| 281 |
new_asset = Asset(
|
| 282 |
id=uid, owner_id=owner, project_name=a["name"],
|
| 283 |
asset_id=a["id"], location=f"Lab Bay {random.randint(1, 20)}", capacity=100.0,
|
| 284 |
bms_provider="ZenVolt Native", category=json.dumps(["Grid-Scale"]),
|
| 285 |
project_stage=a["stage"], health_score=a["health"],
|
| 286 |
remaining_life=round(a["health"]/20, 1), degradation_rate=2.1,
|
| 287 |
+
confidence=0.94, is_online=1, created_at=datetime.utcnow(),
|
| 288 |
+
nft_hash=nft_hash, block_explorer_url=explorer_url,
|
| 289 |
+
nft_mint_date=datetime.utcnow() if nft_hash else None
|
| 290 |
)
|
| 291 |
db.add(new_asset)
|
| 292 |
|