Commit ee3e0be
ref(dashboards): Use favorited column for favorite status instead of row existence (#110204)
Use the `favorited` boolean column on `DashboardFavoriteUser` to
determine
favorite status, rather than checking for existence of a row in the
table.
Previously, unfavoriting a dashboard deleted the `DashboardFavoriteUser`
row entirely. Now it sets `favorited=False` and clears the position,
preserving
the row for potential re-favoriting. This avoids row churn and makes the
favorite state explicit.
Changes:
- All manager queries (`get_favorite_dashboards`,
`get_favorite_dashboard`,
`get_last_position`, `reorder_favorite_dashboards`) now filter by
`favorited=True`
- `insert_favorite_dashboard` reactivates existing unfavorited entries
instead
of always creating new rows
- Renamed `delete_favorite_dashboard` → `unfavorite_dashboard` to
reflect
that the row is no longer deleted
- Updated serializer, list endpoint filters, sort, and pin-by-favorites
queries to scope by `favorited=True`
- Fixed race condition in `insert_favorite_dashboard` using
`select_for_update()`
to prevent concurrent calls from causing `IntegrityError`
- Fixed position assignment bug where re-favoriting the first dashboard
after
unfavoriting all others assigned position 1 instead of 0 due to a global
unscoped count check
Refs DAIN-1287
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 775f265 commit ee3e0be
File tree
5 files changed
+100
-38
lines changed- src/sentry
- api/serializers/models
- dashboards/endpoints
- models
- tests/sentry/models
5 files changed
+100
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
377 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
378 | 382 | | |
379 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
380 | 387 | | |
381 | 388 | | |
382 | 389 | | |
| |||
493 | 500 | | |
494 | 501 | | |
495 | 502 | | |
496 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
497 | 508 | | |
498 | 509 | | |
499 | 510 | | |
| |||
506 | 517 | | |
507 | 518 | | |
508 | 519 | | |
509 | | - | |
| 520 | + | |
510 | 521 | | |
511 | 522 | | |
512 | 523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| 96 | + | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| |||
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
144 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
145 | 160 | | |
146 | 161 | | |
147 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
148 | 166 | | |
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
158 | 181 | | |
159 | 182 | | |
160 | | - | |
| 183 | + | |
161 | 184 | | |
162 | 185 | | |
163 | 186 | | |
164 | | - | |
165 | | - | |
| 187 | + | |
| 188 | + | |
166 | 189 | | |
167 | 190 | | |
168 | 191 | | |
169 | 192 | | |
170 | | - | |
| 193 | + | |
171 | 194 | | |
172 | 195 | | |
173 | 196 | | |
| |||
177 | 200 | | |
178 | 201 | | |
179 | 202 | | |
180 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
181 | 206 | | |
182 | 207 | | |
183 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
184 | 212 | | |
185 | 213 | | |
186 | 214 | | |
| |||
265 | 293 | | |
266 | 294 | | |
267 | 295 | | |
268 | | - | |
| 296 | + | |
269 | 297 | | |
270 | 298 | | |
271 | 299 | | |
| |||
277 | 305 | | |
278 | 306 | | |
279 | 307 | | |
280 | | - | |
281 | | - | |
282 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
283 | 312 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 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 | + | |
294 | 340 | | |
295 | 341 | | |
296 | 342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
0 commit comments