Feedback Review Logic¶
The Feedback Review system allows administrators and developers to analyze user feedback directly within Discord. It combines database queries with matplotlib visualizations to generate interactive reports.
The Administration Cog¶
This Cog handles the /review_feedback command, which fetches data from the database and passes it to the plotting utilities. It is protected by a permission check (may_review_feedback) ensuring only authorized personnel can access sensitive user feedback. Authorized are the developers, the owner of the Discord application and the administrators of the home server, the one DISCORD_SERVER_ID names. An administrator of any other server is refused: OSCAR is a public bot, and anybody is the administrator of a server they made themselves. The answer is ephemeral, so the channel does not see the charts.
src.oscar.cogs.admin.Administration ¶
Bases: Cog
Class for the administration cog.
Source code in src/oscar/cogs/admin.py
review_feedback
async
¶
Command to review feedback given by users.
Source code in src/oscar/cogs/admin.py
The Review View¶
The ReviewFeedbackView is the interactive UI component. It extends TranslatedView to support both English and German.
Key Features:
- Dynamic Filtering: Filters feedback by time range (1 Hour, 12 Hours, 1 Day, 1 Week, 1/6 Months, 1/2/4 Years, All Time).
- Live Updates: Regenerates charts on-the-fly when filters change.
- Data Export: Includes a download button (
⤓) to export the complete dataset as a.jsonfile.
GDPR & Confidentiality Notice: The exported JSON contains pseudonymized feedback linked to Discord User IDs. As an administrator, you must treat this data as confidential and delete local exports once the analysis is complete. Ensure exports are not shared publicly.
src.oscar.cogs.admin.ReviewFeedbackView ¶
ReviewFeedbackView(interaction: Interaction, feedback: list[FeedbackReviewDict], images: list[File], default_language: LanguageCode = LanguageCode.EN)
Bases: TranslatedView
Feedback (review) view that extends TranslatedView for language switching.
Source code in src/oscar/cogs/admin.py
_build_content ¶
Build the feedback (review) view content with current language.
Source code in src/oscar/cogs/admin.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
Visualizations (Matplotlib)¶
The bot uses matplotlib with the Agg backend (headless) to generate images purely in memory (io.BytesIO), preventing GUI blocking on the server.
Limitation (Discord File Sizes): Discord enforces an 8 MB upload limit (25 MB for Nitro servers). For extremely massive datasets, the generated PNG or JSON export may hit this API limit. This typically requires tens of thousands of records.
Boxplots¶
Visualizes the statistical distribution of the three core metrics on a Likert scale from 1 (Very Poor/Disagree) to 4 (Excellent/Agree). It shows medians, quartiles, and outliers.
src.util.plots.create_feedback_boxplot
async
¶
create_feedback_boxplot(feedback_data: list[FeedbackReviewDict], language_code: LanguageCode = LanguageCode.EN) -> File
Create a boxplot visualization of feedback metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feedback_data
|
list[FeedbackReviewDict]
|
List of feedback dictionaries |
required |
Returns:
| Type | Description |
|---|---|
File
|
Discord file object containing the plot image |
Source code in src/util/plots.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
Timelines¶
Visualizes feedback volume over time. It uses dynamic binning (hourly/daily/weekly) depending on the selected time span and highlights the active filter range.
src.util.plots.create_feedback_timeline
async
¶
create_feedback_timeline(feedback_data: list[FeedbackReviewDict], selected_duration: int | None = None, language_code: LanguageCode = LanguageCode.EN) -> File
Create a timeline visualization of feedback timestamps with highlighted selected range. Now renders a line graph showing counts of feedback over time and highlights the selected range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feedback_data
|
list[FeedbackReviewDict]
|
List of feedback dictionaries containing timestamps |
required |
selected_duration
|
int | None
|
Duration in seconds from current time to highlight (None = all time) |
None
|
language_code
|
LanguageCode
|
Language code for labels |
EN
|
Returns:
| Type | Description |
|---|---|
File
|
Discord file object containing the timeline plot |
Source code in src/util/plots.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
Data Model¶
The visualizations are based on the following typed dictionary structure retrieved from the SQLite database:
src.util.typed_dicts.FeedbackReviewDict ¶
Bases: TypedDict
Defines the shape of the stored Feedback review data.