vargha commited on
Commit
60fd07f
Β·
1 Parent(s): c7d38be

improving progress bar interface

Browse files
Files changed (1) hide show
  1. components/review_dashboard_page.py +58 -8
components/review_dashboard_page.py CHANGED
@@ -177,16 +177,16 @@ class ReviewDashboardPage:
177
  return validation_status, is_deleted
178
 
179
  def get_review_progress_fn(session):
180
- """Calculate review progress for the current reviewer"""
181
  user_id = session.get("user_id")
182
  username = session.get("username")
183
 
184
  if not user_id or not username:
185
- return "Review Progress: N/A"
186
 
187
  # Check if user is a reviewer
188
  if username not in conf.REVIEW_MAPPING.values():
189
- return "Review Progress: N/A (Not a reviewer)"
190
 
191
  # Find target annotator
192
  target_annotator = None
@@ -196,14 +196,14 @@ class ReviewDashboardPage:
196
  break
197
 
198
  if not target_annotator:
199
- return "Review Progress: N/A (No target annotator)"
200
 
201
  with get_db() as db:
202
  try:
203
  # Get target annotator's ID
204
  target_annotator_obj = db.query(Annotator).filter_by(name=target_annotator).first()
205
  if not target_annotator_obj:
206
- return f"Review Progress: Error (Annotator '{target_annotator}' not found)"
207
 
208
  # Count total annotations for target annotator
209
  total_count = db.query(Annotation).filter(
@@ -220,13 +220,63 @@ class ReviewDashboardPage:
220
 
221
  if total_count > 0:
222
  percentage = (reviewed_count / total_count) * 100
223
- return f"**Review Progress:** {reviewed_count}/{total_count} ({percentage:.1f}%) - Reviewing {target_annotator}'s work"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  else:
225
- return f"**Review Progress:** No items found for {target_annotator}"
226
 
227
  except Exception as e:
228
  log.error(f"Error calculating review progress for user {user_id}: {e}")
229
- return "Review Progress: Error calculating progress"
230
 
231
  def load_review_items_fn(session):
232
  user_id = session.get("user_id")
 
177
  return validation_status, is_deleted
178
 
179
  def get_review_progress_fn(session):
180
+ """Calculate review progress for the current reviewer with beautiful tqdm-style display"""
181
  user_id = session.get("user_id")
182
  username = session.get("username")
183
 
184
  if not user_id or not username:
185
+ return ""
186
 
187
  # Check if user is a reviewer
188
  if username not in conf.REVIEW_MAPPING.values():
189
+ return ""
190
 
191
  # Find target annotator
192
  target_annotator = None
 
196
  break
197
 
198
  if not target_annotator:
199
+ return ""
200
 
201
  with get_db() as db:
202
  try:
203
  # Get target annotator's ID
204
  target_annotator_obj = db.query(Annotator).filter_by(name=target_annotator).first()
205
  if not target_annotator_obj:
206
+ return f"⚠️ **Error:** Annotator '{target_annotator}' not found"
207
 
208
  # Count total annotations for target annotator
209
  total_count = db.query(Annotation).filter(
 
220
 
221
  if total_count > 0:
222
  percentage = (reviewed_count / total_count) * 100
223
+
224
+ # Create tqdm-style progress bar
225
+ bar_width = 30 # Width of the progress bar in characters
226
+ filled = int((percentage / 100) * bar_width)
227
+ empty = bar_width - filled
228
+
229
+ # Different colors based on progress
230
+ if percentage < 25:
231
+ color = "πŸ”΄" # Red for low progress
232
+ bar_color = "progress-bar-low"
233
+ elif percentage < 50:
234
+ color = "🟑" # Yellow for medium-low progress
235
+ bar_color = "progress-bar-medium-low"
236
+ elif percentage < 75:
237
+ color = "🟠" # Orange for medium progress
238
+ bar_color = "progress-bar-medium"
239
+ elif percentage < 100:
240
+ color = "🟒" # Green for high progress
241
+ bar_color = "progress-bar-high"
242
+ else:
243
+ color = "βœ…" # Check mark for complete
244
+ bar_color = "progress-bar-complete"
245
+
246
+ # Create the visual progress bar with Unicode blocks
247
+ progress_bar = "β–ˆ" * filled + "β–‘" * empty
248
+
249
+ # Estimate remaining items
250
+ remaining = total_count - reviewed_count
251
+
252
+ # Create the beautiful progress display
253
+ progress_html = f"""
254
+ <div class="progress-container">
255
+ <div class="progress-header">
256
+ <span class="progress-icon">{color}</span>
257
+ <strong>Review Progress - {target_annotator}'s work</strong>
258
+ </div>
259
+ <div class="progress-bar-container">
260
+ <span class="progress-percentage">{percentage:.1f}%</span>
261
+ <div class="progress-bar {bar_color}">
262
+ <span class="progress-fill" style="width: {percentage:.1f}%"></span>
263
+ </div>
264
+ <span class="progress-stats">{reviewed_count}/{total_count}</span>
265
+ </div>
266
+ <div class="progress-details">
267
+ πŸ“Š <code>{progress_bar}</code>
268
+ <span class="remaining-items">({remaining} remaining)</span>
269
+ </div>
270
+ </div>
271
+ """
272
+
273
+ return progress_html
274
  else:
275
+ return f"πŸ“­ **No items found for {target_annotator}**"
276
 
277
  except Exception as e:
278
  log.error(f"Error calculating review progress for user {user_id}: {e}")
279
+ return f"⚠️ **Error calculating progress**"
280
 
281
  def load_review_items_fn(session):
282
  user_id = session.get("user_id")