Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified backend/__pycache__/jules_engine.cpython-312.pyc
Binary file not shown.
Binary file modified backend/__pycache__/main.cpython-312.pyc
Binary file not shown.
Binary file modified backend/__pycache__/models.cpython-312.pyc
Binary file not shown.
7 changes: 5 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@

# 🛡️ Configuración Maestra (abvetos.com) - Secrets moved to environment variables
SECRET_KEY = os.getenv("LVT_SECRET_KEY", "DEVELOPMENT_SECRET_DO_NOT_USE_IN_PROD")
# Pre-encode secret key to bytes to save redundant encoding operations
SECRET_KEY_BYTES = SECRET_KEY.encode()
PATENT = "PCT/EP2025/067317"

def verify_auth(user_id: str, token: str) -> bool:
try:
ts, sig = token.split('.')
if int(time.time()) - int(ts) > 600: return False # Ventana 10 min
expected = hmac.new(SECRET_KEY.encode(), f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
# Optimization: Use pre-encoded SECRET_KEY_BYTES
expected = hmac.new(SECRET_KEY_BYTES, f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(sig, expected)
except: return False

Expand All @@ -50,7 +53,7 @@ def calculate_fit(user_waist: float, item_id: str):
return is_perfect, round(fit_index, 3), item

@app.post("/api/recommend")
async def recommend_garment(scan: UserScan, garment_id: str = "BALMAIN_SS26_SLIM"):
def recommend_garment(scan: UserScan, garment_id: str = "BALMAIN_SS26_SLIM"):
# 1. Seguridad y Handshake
if not verify_auth(scan.user_id, scan.token):
raise HTTPException(status_code=403, detail="Acceso restringido al búnker.")
Expand Down
Binary file modified backend/tests/__pycache__/test_main.cpython-312-pytest-9.0.2.pyc
Binary file not shown.
20 changes: 16 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class TryOnYouBunker {
this.selectedGarmentId = "BALMAIN_SS26_SLIM";
this.version = "11.0.0";
this.biometricAnalyzer = new MediaPipeBiometricAnalyzer();
// Performance: Cache frequently accessed DOM elements
this.dom = {
resultContainer: document.getElementById('jules-result'),
resultText: document.getElementById('recommendation-text'),
submitBtn: null // Assigned in handleDivineoExecution for contextual accuracy if needed
};
Comment on lines +39 to +43
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and to make dependencies explicit, it would be better to also cache the submit button here. The current implementation caches it on first use in handleDivineoExecution, which can be fragile if the handler is ever reused for a different form. Since the form has a stable ID (#jules-form), you can reliably select the button in the constructor.

Suggested change
this.dom = {
resultContainer: document.getElementById('jules-result'),
resultText: document.getElementById('recommendation-text'),
submitBtn: null // Assigned in handleDivineoExecution for contextual accuracy if needed
};
this.dom = {
resultContainer: document.getElementById('jules-result'),
resultText: document.getElementById('recommendation-text'),
submitBtn: document.querySelector('#jules-form button[type="submit"]')
};

this.shopifyInventory = {
"BALMAIN_SS26_SLIM": {
"name": "Balmain Slim-Fit Jeans",
Expand Down Expand Up @@ -111,9 +117,13 @@ class TryOnYouBunker {
const formData = new FormData(event.target);
const eventType = formData.get('event_type');

const resultContainer = document.getElementById('jules-result');
const resultText = document.getElementById('recommendation-text');
const submitBtn = event.target.querySelector('button[type="submit"]');
// Performance: Re-use cached DOM or cache it once
const resultContainer = this.dom.resultContainer;
const resultText = this.dom.resultText;
if (!this.dom.submitBtn) {
this.dom.submitBtn = event.target.querySelector('button[type="submit"]');
}
const submitBtn = this.dom.submitBtn;
Comment on lines +121 to +126
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Following the suggestion to cache the submit button in the constructor, this block can be simplified significantly by destructuring all needed DOM elements from this.dom.

Suggested change
const resultContainer = this.dom.resultContainer;
const resultText = this.dom.resultText;
if (!this.dom.submitBtn) {
this.dom.submitBtn = event.target.querySelector('button[type="submit"]');
}
const submitBtn = this.dom.submitBtn;
const { resultContainer, resultText, submitBtn } = this.dom;


try {
submitBtn.innerHTML = '<span class="loader"></span> EXECUTING DIVINEO TOTALITY...';
Expand Down Expand Up @@ -211,11 +221,13 @@ class TryOnYouBunker {
}

applyLuxuryTransitions() {
const observer = new IntersectionObserver((entries) => {
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
// Performance: Unobserve after transition to save resources
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
Expand Down