Commit 33f4cca
committed
⚡️(backend) reduce queries made in item access list viewset
The ItemAvvessViewset list endpoint is really complicated and half of
the algo is made to cache the role the current user have on the tree.
This code is now removed and replaced by a queryset annotation allowing
to fetch the user_roles and then determine in the model the max role the
user have on the tree. It reduces the number of sql query by 1 and ease
the code comprehension1 parent 55c1f45 commit 33f4cca
File tree
3 files changed
+73
-112
lines changed- src/backend/core
- api
- tests/items
3 files changed
+73
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
| 1189 | + | |
1192 | 1190 | | |
1193 | | - | |
| 1191 | + | |
1194 | 1192 | | |
1195 | | - | |
| 1193 | + | |
| 1194 | + | |
1196 | 1195 | | |
1197 | 1196 | | |
1198 | 1197 | | |
1199 | 1198 | | |
1200 | 1199 | | |
1201 | 1200 | | |
1202 | 1201 | | |
1203 | | - | |
| 1202 | + | |
| 1203 | + | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
| |||
1215 | 1215 | | |
1216 | 1216 | | |
1217 | 1217 | | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
| 1218 | + | |
1236 | 1219 | | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1248 | 1225 | | |
1249 | 1226 | | |
1250 | 1227 | | |
1251 | 1228 | | |
1252 | 1229 | | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
| 1230 | + | |
1261 | 1231 | | |
1262 | 1232 | | |
1263 | 1233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1103 | 1103 | | |
1104 | 1104 | | |
1105 | 1105 | | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1106 | 1137 | | |
1107 | 1138 | | |
1108 | 1139 | | |
| |||
1122 | 1153 | | |
1123 | 1154 | | |
1124 | 1155 | | |
| 1156 | + | |
| 1157 | + | |
1125 | 1158 | | |
1126 | 1159 | | |
1127 | 1160 | | |
| |||
1166 | 1199 | | |
1167 | 1200 | | |
1168 | 1201 | | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | 1202 | | |
1229 | 1203 | | |
1230 | 1204 | | |
| |||
1281 | 1255 | | |
1282 | 1256 | | |
1283 | 1257 | | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
1284 | 1273 | | |
1285 | 1274 | | |
1286 | 1275 | | |
1287 | 1276 | | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
| 1277 | + | |
| 1278 | + | |
1291 | 1279 | | |
1292 | 1280 | | |
1293 | | - | |
| 1281 | + | |
1294 | 1282 | | |
1295 | 1283 | | |
1296 | 1284 | | |
| |||
1306 | 1294 | | |
1307 | 1295 | | |
1308 | 1296 | | |
1309 | | - | |
| 1297 | + | |
1310 | 1298 | | |
1311 | 1299 | | |
1312 | 1300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
1492 | 1492 | | |
1493 | 1493 | | |
1494 | 1494 | | |
1495 | | - | |
| 1495 | + | |
1496 | 1496 | | |
1497 | 1497 | | |
1498 | 1498 | | |
| |||
1517 | 1517 | | |
1518 | 1518 | | |
1519 | 1519 | | |
1520 | | - | |
| 1520 | + | |
| 1521 | + | |
1521 | 1522 | | |
1522 | 1523 | | |
1523 | 1524 | | |
| |||
1616 | 1617 | | |
1617 | 1618 | | |
1618 | 1619 | | |
1619 | | - | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1620 | 1623 | | |
1621 | 1624 | | |
1622 | 1625 | | |
| |||
0 commit comments