deedrop1140 commited on
Commit
4518d00
·
verified ·
1 Parent(s): 45c75d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -549,7 +549,7 @@ def dashboard():
549
  return render_template("dashboard.html", total=total, neg=neg, pos=pos, neu=neu)
550
 
551
  @app.route('/admin/negatives')
552
- @login_required # still requires login, but not admin
553
  def admin_negatives():
554
  negatives = ChatMessage.query.filter_by(sentiment="Negative")\
555
  .order_by(ChatMessage.created_at.desc())\
@@ -557,6 +557,26 @@ def admin_negatives():
557
  return render_template("admin_negatives.html", negatives=negatives)
558
 
559
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
 
561
  # ---------------------------
562
  # Add this to app.py (place it under your existing admin_negatives route)
 
549
  return render_template("dashboard.html", total=total, neg=neg, pos=pos, neu=neu)
550
 
551
  @app.route('/admin/negatives')
552
+ @login_required
553
  def admin_negatives():
554
  negatives = ChatMessage.query.filter_by(sentiment="Negative")\
555
  .order_by(ChatMessage.created_at.desc())\
 
557
  return render_template("admin_negatives.html", negatives=negatives)
558
 
559
 
560
+ @app.route('/admin/negatives-data')
561
+ @login_required
562
+ def admin_negatives_data():
563
+ negatives = ChatMessage.query.filter_by(sentiment="Negative")\
564
+ .order_by(ChatMessage.created_at.desc())\
565
+ .limit(200).all()
566
+ return jsonify([
567
+ {
568
+ "id": n.id,
569
+ "user": n.username,
570
+ "message": n.message,
571
+ "category": n.category,
572
+ "status": n.status,
573
+ "time": n.created_at.strftime("%Y-%m-%d %H:%M:%S")
574
+ }
575
+ for n in negatives
576
+ ])
577
+
578
+
579
+
580
 
581
  # ---------------------------
582
  # Add this to app.py (place it under your existing admin_negatives route)