Spaces:
Running
Running
thadillo
commited on
Commit
·
af68c84
1
Parent(s):
f037336
Enable sentence-level view for map and contributions
Browse files- app/routes/admin.py +45 -4
app/routes/admin.py
CHANGED
|
@@ -128,11 +128,32 @@ def dashboard():
|
|
| 128 |
if view_mode == 'sentences':
|
| 129 |
# SENTENCE-LEVEL VIEW
|
| 130 |
|
| 131 |
-
# Get all sentences with categories
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
SubmissionSentence.category != None
|
| 134 |
).all()
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
# Category stats
|
| 137 |
category_stats = db.session.query(
|
| 138 |
SubmissionSentence.category,
|
|
@@ -242,11 +263,31 @@ def export_dashboard_pdf():
|
|
| 242 |
if view_mode == 'sentences':
|
| 243 |
# SENTENCE-LEVEL VIEW
|
| 244 |
|
| 245 |
-
# Get all sentences with categories
|
| 246 |
-
|
|
|
|
|
|
|
| 247 |
SubmissionSentence.category != None
|
| 248 |
).all()
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
# Category stats
|
| 251 |
category_stats = db.session.query(
|
| 252 |
SubmissionSentence.category,
|
|
|
|
| 128 |
if view_mode == 'sentences':
|
| 129 |
# SENTENCE-LEVEL VIEW
|
| 130 |
|
| 131 |
+
# Get all sentences with categories joined with their parent submissions
|
| 132 |
+
sentences_query = db.session.query(SubmissionSentence, Submission).join(
|
| 133 |
+
Submission
|
| 134 |
+
).filter(
|
| 135 |
SubmissionSentence.category != None
|
| 136 |
).all()
|
| 137 |
|
| 138 |
+
# Create enhanced sentence objects with submission data
|
| 139 |
+
sentences = []
|
| 140 |
+
for sentence, submission in sentences_query:
|
| 141 |
+
# Create object with both sentence and submission attributes
|
| 142 |
+
class EnhancedSentence:
|
| 143 |
+
def __init__(self, sentence, submission):
|
| 144 |
+
self.id = sentence.id
|
| 145 |
+
self.text = sentence.text
|
| 146 |
+
self.message = sentence.text # For template compatibility
|
| 147 |
+
self.category = sentence.category
|
| 148 |
+
self.confidence = sentence.confidence
|
| 149 |
+
self.contributor_type = submission.contributor_type
|
| 150 |
+
self.timestamp = submission.timestamp
|
| 151 |
+
self.latitude = submission.latitude
|
| 152 |
+
self.longitude = submission.longitude
|
| 153 |
+
self.submission_id = submission.id
|
| 154 |
+
|
| 155 |
+
sentences.append(EnhancedSentence(sentence, submission))
|
| 156 |
+
|
| 157 |
# Category stats
|
| 158 |
category_stats = db.session.query(
|
| 159 |
SubmissionSentence.category,
|
|
|
|
| 263 |
if view_mode == 'sentences':
|
| 264 |
# SENTENCE-LEVEL VIEW
|
| 265 |
|
| 266 |
+
# Get all sentences with categories joined with their parent submissions
|
| 267 |
+
sentences_query = db.session.query(SubmissionSentence, Submission).join(
|
| 268 |
+
Submission
|
| 269 |
+
).filter(
|
| 270 |
SubmissionSentence.category != None
|
| 271 |
).all()
|
| 272 |
|
| 273 |
+
# Create enhanced sentence objects with submission data
|
| 274 |
+
sentences = []
|
| 275 |
+
for sentence, submission in sentences_query:
|
| 276 |
+
class EnhancedSentence:
|
| 277 |
+
def __init__(self, sentence, submission):
|
| 278 |
+
self.id = sentence.id
|
| 279 |
+
self.text = sentence.text
|
| 280 |
+
self.message = sentence.text # For template compatibility
|
| 281 |
+
self.category = sentence.category
|
| 282 |
+
self.confidence = sentence.confidence
|
| 283 |
+
self.contributor_type = submission.contributor_type
|
| 284 |
+
self.timestamp = submission.timestamp
|
| 285 |
+
self.latitude = submission.latitude
|
| 286 |
+
self.longitude = submission.longitude
|
| 287 |
+
self.submission_id = submission.id
|
| 288 |
+
|
| 289 |
+
sentences.append(EnhancedSentence(sentence, submission))
|
| 290 |
+
|
| 291 |
# Category stats
|
| 292 |
category_stats = db.session.query(
|
| 293 |
SubmissionSentence.category,
|