phhttps commited on
Commit
dadb2ec
·
1 Parent(s): f00df58

Separate Airbnb and Booking results into distinct sections and increase to top 15 each

Browse files
Files changed (3) hide show
  1. api.py +8 -7
  2. frontend_dashboard.html +69 -43
  3. holland_agent.py +7 -1
api.py CHANGED
@@ -76,13 +76,14 @@ async def search_deals(
76
  )
77
  print(f"--- [API Request] Agent fertig. {results.get('total_deals_found')} Deals gefunden.")
78
 
79
- # Optional: Ensure image_url has a fallback for the frontend
80
- final_deals = results.get("top_10_deals", [])
81
- for deal in final_deals:
82
- if not deal.get("image_url"):
83
- deal["image_url"] = "https://via.placeholder.com/800x450.png?text=KEIN+BILD+GEFUNDEN"
84
-
85
- results["top_10_deals"] = final_deals
 
86
  return results
87
 
88
  if __name__ == "__main__":
 
76
  )
77
  print(f"--- [API Request] Agent fertig. {results.get('total_deals_found')} Deals gefunden.")
78
 
79
+ # Process all deal lists for image fallbacks
80
+ for key in ["top_10_deals", "top_airbnb_deals", "top_booking_deals"]:
81
+ deals = results.get(key, [])
82
+ for deal in deals:
83
+ if not deal.get("image_url"):
84
+ deal["image_url"] = "https://via.placeholder.com/800x450.png?text=KEIN+BILD+GEFUNDEN"
85
+ results[key] = deals
86
+
87
  return results
88
 
89
  if __name__ == "__main__":
frontend_dashboard.html CHANGED
@@ -45,18 +45,18 @@
45
  <div class="grid grid-cols-2 gap-2">
46
  <div>
47
  <label class="block text-sm font-medium text-gray-700">Check-In</label>
48
- <input type="date" id="input-checkin" value="2026-02-15" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
49
  </div>
50
  <div>
51
  <label class="block text-sm font-medium text-gray-700">Check-Out</label>
52
- <input type="date" id="input-checkout" value="2026-02-22" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
53
  </div>
54
  </div>
55
 
56
  <div class="grid grid-cols-2 gap-2">
57
  <div>
58
  <label class="block text-sm font-medium text-gray-700">Erwachsene</label>
59
- <input type="number" id="input-adults" value="4" min="1" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
60
  </div>
61
  <div>
62
  <label class="block text-sm font-medium text-gray-700">Kinder</label>
@@ -88,22 +88,38 @@
88
 
89
  <!-- Main Content -->
90
  <main class="w-full lg:w-3/4">
91
- <div class="flex justify-between items-end mb-6">
92
- <div>
93
- <h2 class="text-3xl font-bold text-gray-800">Top Empfehlungen</h2>
94
- <p id="status-text" class="text-gray-500">Gefundene Deals für Holland im Februar 2026</p>
95
- </div>
96
- <div class="text-sm text-gray-500">Sortiert nach: <span class="font-semibold text-emerald-600 underline">Beste Bewertung</span></div>
97
  </div>
98
 
99
- <!-- Deal Grid -->
100
- <div id="deal-grid" class="grid md:grid-cols-2 gap-6">
101
- <!-- Initialer Lade-Zustand oder Platzhalter -->
102
- <div class="col-span-2 text-center py-20 text-gray-400">
103
- <i class="fa-solid fa-search fa-3x mb-4"></i>
104
- <p>Klicke auf "Angebote finden", um die Suche zu starten.</p>
105
  </div>
106
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  </main>
108
  </div>
109
 
@@ -116,7 +132,8 @@
116
 
117
  <script>
118
  const searchBtn = document.getElementById('search-btn');
119
- const dealGrid = document.getElementById('deal-grid');
 
120
  const statusText = document.getElementById('status-text');
121
 
122
  searchBtn.addEventListener('click', async () => {
@@ -137,65 +154,74 @@
137
  // Lade-Anzeige
138
  searchBtn.disabled = true;
139
  searchBtn.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin mr-2"></i> Suche läuft...';
140
- dealGrid.innerHTML = '<div class="col-span-2 text-center py-20"><i class="fa-solid fa-compass fa-spin fa-3x text-emerald-600 mb-4"></i><p class="text-lg font-bold">Live-Suche aktiv...</p><p class="text-gray-500">Wir durchsuchen Booking.com und Airbnb (ca. 60 Sek.)</p></div>';
 
 
 
141
 
142
  try {
143
  const url = `/search?cities=${encodeURIComponent(cities)}&checkin=${checkin}&checkout=${checkout}&adults=${adults}&children=${children}&pets=${pets}&budget=${budget}&budget_type=${budgetType}`;
144
  const response = await fetch(url);
145
  const data = await response.json();
146
 
147
- renderDeals(data.top_10_deals);
148
- statusText.innerText = `${data.top_10_deals.length} echte Deals verifiziert für ${data.search_params.nights} Nächte`;
 
 
149
  } catch (error) {
150
  console.error('Error:', error);
151
- dealGrid.innerHTML = '<div class="col-span-2 text-center py-20 text-red-500"><i class="fa-solid fa-circle-exclamation fa-3x mb-4"></i><p>Fehler bei der Suche. Ist das Backend online?</p></div>';
 
 
152
  } finally {
153
  searchBtn.disabled = false;
154
  searchBtn.innerHTML = 'Angebote finden';
155
  }
156
  });
157
 
158
- function renderDeals(deals) {
 
159
  if (!deals || deals.length === 0) {
160
- dealGrid.innerHTML = '<div class="col-span-2 text-center py-20"><p>Keine Angebote gefunden. Versuche es mit anderen Daten oder Zielen.</p></div>';
161
  return;
162
  }
163
 
164
- dealGrid.innerHTML = deals.map(deal => `
165
- <div class="deal-card bg-white rounded-2xl shadow-sm overflow-hidden border border-gray-100 flex flex-col">
166
  <div class="relative h-48 bg-gray-200">
167
  <img src="${deal.image_url}"
168
  onerror="this.src='https://via.placeholder.com/800x450.png?text=BILD-LADE-FEHLER'"
169
  alt="${deal.name}"
170
  class="object-cover w-full h-full">
171
  <div class="absolute top-4 left-4 bg-white/90 backdrop-blur px-3 py-1 rounded-full text-xs font-bold text-emerald-700 flex items-center">
172
- <i class="fa-solid fa-sun mr-1"></i> Wetter Bonus aktiv
173
  </div>
174
  <div class="absolute top-4 right-4 bg-emerald-600 text-white px-3 py-1 rounded-full text-xs font-bold">
175
- ${deal.rank_score} Score
176
  </div>
177
  </div>
178
- <div class="p-5 flex-grow">
179
  <div class="flex justify-between items-start mb-2">
180
- <h3 class="text-lg font-bold">${deal.name}</h3>
181
- ${deal.pet_friendly ? '<span class="bg-blue-100 text-blue-700 text-[10px] uppercase font-black px-2 py-0.5 rounded">Hundefreundlich</span>' : ''}
182
  </div>
183
- <p class="text-gray-500 text-sm mb-4"><i class="fa-solid fa-location-dot mr-1 text-emerald-500"></i> ${deal.location}</p>
184
 
185
- <div class="flex justify-between items-center border-t pt-4 mt-auto">
186
- <div>
187
- <p class="text-xs text-gray-400">Preis pro Nacht</p>
188
- <p class="text-xl font-bold text-emerald-700">€${deal.price_per_night}</p>
189
- </div>
190
- <div class="text-right">
191
- <p class="text-xs text-gray-400">Gesamtpreis</p>
192
- <p class="text-lg font-semibold text-gray-800">€${deal.total_cost_for_trip}</p>
 
 
193
  </div>
 
 
 
194
  </div>
195
- <p class="text-[10px] text-emerald-600 font-bold mt-2 uppercase tracking-wider">${deal.recommendation.split('|')[0]}</p>
196
- <a href="${deal.url}" target="_blank" rel="noreferrer" referrerpolicy="no-referrer" class="block w-full mt-4 bg-white border-2 border-emerald-600 text-emerald-600 py-2 rounded-lg font-bold hover:bg-emerald-50 transition text-center">
197
- Details (via ${deal.source})
198
- </a>
199
  </div>
200
  </div>
201
  `).join('');
 
45
  <div class="grid grid-cols-2 gap-2">
46
  <div>
47
  <label class="block text-sm font-medium text-gray-700">Check-In</label>
48
+ <input type="date" id="input-checkin" value="2026-03-08" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
49
  </div>
50
  <div>
51
  <label class="block text-sm font-medium text-gray-700">Check-Out</label>
52
+ <input type="date" id="input-checkout" value="2026-03-15" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
53
  </div>
54
  </div>
55
 
56
  <div class="grid grid-cols-2 gap-2">
57
  <div>
58
  <label class="block text-sm font-medium text-gray-700">Erwachsene</label>
59
+ <input type="number" id="input-adults" value="2" min="1" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm p-2 bg-gray-50 border">
60
  </div>
61
  <div>
62
  <label class="block text-sm font-medium text-gray-700">Kinder</label>
 
88
 
89
  <!-- Main Content -->
90
  <main class="w-full lg:w-3/4">
91
+ <div class="mb-8">
92
+ <h2 class="text-3xl font-bold text-gray-800">Deine Urlaubs-Deals</h2>
93
+ <p id="status-text" class="text-gray-500">Gefundene Deals für Holland</p>
 
 
 
94
  </div>
95
 
96
+ <!-- Airbnb Section -->
97
+ <section class="mb-12">
98
+ <div class="flex items-center mb-6 border-b pb-2">
99
+ <i class="fa-brands fa-airbnb text-red-500 text-2xl mr-3"></i>
100
+ <h2 class="text-2xl font-bold text-gray-700">Airbnb Empfehlungen</h2>
 
101
  </div>
102
+ <div id="airbnb-grid" class="grid md:grid-cols-2 gap-6">
103
+ <div class="col-span-2 text-center py-10 text-gray-400">
104
+ <i class="fa-solid fa-search fa-2x mb-2"></i>
105
+ <p>Noch keine Suche gestartet.</p>
106
+ </div>
107
+ </div>
108
+ </section>
109
+
110
+ <!-- Booking Section -->
111
+ <section>
112
+ <div class="flex items-center mb-6 border-b pb-2">
113
+ <i class="fa-solid fa-hotel text-blue-600 text-2xl mr-3"></i>
114
+ <h2 class="text-2xl font-bold text-gray-700">Booking.com Favoriten</h2>
115
+ </div>
116
+ <div id="booking-grid" class="grid md:grid-cols-2 gap-6">
117
+ <div class="col-span-2 text-center py-10 text-gray-400">
118
+ <i class="fa-solid fa-search fa-2x mb-2"></i>
119
+ <p>Noch keine Suche gestartet.</p>
120
+ </div>
121
+ </div>
122
+ </section>
123
  </main>
124
  </div>
125
 
 
132
 
133
  <script>
134
  const searchBtn = document.getElementById('search-btn');
135
+ const airbnbGrid = document.getElementById('airbnb-grid');
136
+ const bookingGrid = document.getElementById('booking-grid');
137
  const statusText = document.getElementById('status-text');
138
 
139
  searchBtn.addEventListener('click', async () => {
 
154
  // Lade-Anzeige
155
  searchBtn.disabled = true;
156
  searchBtn.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin mr-2"></i> Suche läuft...';
157
+
158
+ const loadingHtml = '<div class="col-span-2 text-center py-20"><i class="fa-solid fa-compass fa-spin fa-3x text-emerald-600 mb-4"></i><p class="text-lg font-bold">Suche läuft...</p></div>';
159
+ airbnbGrid.innerHTML = loadingHtml;
160
+ bookingGrid.innerHTML = loadingHtml;
161
 
162
  try {
163
  const url = `/search?cities=${encodeURIComponent(cities)}&checkin=${checkin}&checkout=${checkout}&adults=${adults}&children=${children}&pets=${pets}&budget=${budget}&budget_type=${budgetType}`;
164
  const response = await fetch(url);
165
  const data = await response.json();
166
 
167
+ renderDeals(data.top_airbnb_deals, 'airbnb');
168
+ renderDeals(data.top_booking_deals, 'booking');
169
+
170
+ statusText.innerText = `${data.total_deals_found} Deals verarbeitet für ${data.search_params.nights} Nächte`;
171
  } catch (error) {
172
  console.error('Error:', error);
173
+ const errorHtml = '<div class="col-span-2 text-center py-20 text-red-500"><i class="fa-solid fa-circle-exclamation fa-3x mb-4"></i><p>Fehler bei der Suche.</p></div>';
174
+ airbnbGrid.innerHTML = errorHtml;
175
+ bookingGrid.innerHTML = errorHtml;
176
  } finally {
177
  searchBtn.disabled = false;
178
  searchBtn.innerHTML = 'Angebote finden';
179
  }
180
  });
181
 
182
+ function renderDeals(deals, source) {
183
+ const targetGrid = document.getElementById(source + '-grid');
184
  if (!deals || deals.length === 0) {
185
+ targetGrid.innerHTML = '<div class="col-span-2 text-center py-10"><p class="text-gray-400 italic">Keine passenden Angebote für diese Quelle gefunden.</p></div>';
186
  return;
187
  }
188
 
189
+ targetGrid.innerHTML = deals.map(deal => `
190
+ <div class="deal-card bg-white rounded-2xl shadow-sm overflow-hidden border border-gray-100 flex flex-col h-full">
191
  <div class="relative h-48 bg-gray-200">
192
  <img src="${deal.image_url}"
193
  onerror="this.src='https://via.placeholder.com/800x450.png?text=BILD-LADE-FEHLER'"
194
  alt="${deal.name}"
195
  class="object-cover w-full h-full">
196
  <div class="absolute top-4 left-4 bg-white/90 backdrop-blur px-3 py-1 rounded-full text-xs font-bold text-emerald-700 flex items-center">
197
+ <i class="fa-solid fa-star text-yellow-500 mr-1"></i> ${deal.rating}
198
  </div>
199
  <div class="absolute top-4 right-4 bg-emerald-600 text-white px-3 py-1 rounded-full text-xs font-bold">
200
+ Score: ${deal.rank_score}
201
  </div>
202
  </div>
203
+ <div class="p-5 flex-grow flex flex-col">
204
  <div class="flex justify-between items-start mb-2">
205
+ <h3 class="text-md font-bold leading-tight">${deal.name}</h3>
206
+ ${deal.pet_friendly ? '<span title="Hunde erlaubt" class="text-emerald-600"><i class="fa-solid fa-dog"></i></span>' : ''}
207
  </div>
208
+ <p class="text-gray-500 text-xs mb-4"><i class="fa-solid fa-location-dot mr-1"></i> ${deal.location}</p>
209
 
210
+ <div class="mt-auto border-t pt-4">
211
+ <div class="flex justify-between items-center">
212
+ <div>
213
+ <p class="text-[10px] text-gray-400 uppercase font-bold">Pro Nacht</p>
214
+ <p class="text-lg font-bold text-emerald-700">€${deal.price_per_night}</p>
215
+ </div>
216
+ <div class="text-right">
217
+ <p class="text-[10px] text-gray-400 uppercase font-bold">Gesamtpreis</p>
218
+ <p class="text-md font-semibold text-gray-800">€${deal.total_cost_for_trip}</p>
219
+ </div>
220
  </div>
221
+ <a href="${deal.url}" target="_blank" rel="noreferrer" class="block w-full mt-4 bg-gray-50 border border-gray-200 text-gray-700 py-2 rounded-lg font-bold hover:bg-gray-100 transition text-center text-sm">
222
+ Zum Angebot <i class="fa-solid fa-external-link ml-1 text-[10px]"></i>
223
+ </a>
224
  </div>
 
 
 
 
225
  </div>
226
  </div>
227
  `).join('');
holland_agent.py CHANGED
@@ -119,6 +119,10 @@ class VacationAgent:
119
  print("📊 Ranking deals...\n")
120
  ranked = self.ranker.rank_deals(self.all_deals, nights)
121
 
 
 
 
 
122
  # Generate summary
123
  summary = self.ranker.generate_summary(ranked, nights)
124
 
@@ -137,7 +141,9 @@ class VacationAgent:
137
  "budget_range": f"€{self.budget_min}-{self.budget_max}"
138
  },
139
  "total_deals_found": len(self.all_deals),
140
- "top_10_deals": ranked[:10],
 
 
141
  "summary": summary
142
  }
143
 
 
119
  print("📊 Ranking deals...\n")
120
  ranked = self.ranker.rank_deals(self.all_deals, nights)
121
 
122
+ # Separate deals by source
123
+ airbnb_deals = [d for d in ranked if "airbnb" in d.get("source", "").lower()]
124
+ booking_deals = [d for d in ranked if "booking" in d.get("source", "").lower()]
125
+
126
  # Generate summary
127
  summary = self.ranker.generate_summary(ranked, nights)
128
 
 
141
  "budget_range": f"€{self.budget_min}-{self.budget_max}"
142
  },
143
  "total_deals_found": len(self.all_deals),
144
+ "top_airbnb_deals": airbnb_deals[:15],
145
+ "top_booking_deals": booking_deals[:15],
146
+ "top_10_deals": ranked[:10], # Keep for backward compatibility
147
  "summary": summary
148
  }
149