MagiCircles / BanGDream

Bandori Party - The BanG Dream! Girls Band Party Database & Community
http://bandori.party/
61 stars 7 forks source link

Asset Duplication w/ Band Filter for Comics #163

Closed LatidoReMe closed 5 years ago

LatidoReMe commented 5 years ago

We definitely need this fixed before we launch the gallery, but until then it's of minor concern.

All I did was filter band, and got this: image

I was fixing how some of the stuff was labeled (the recent script made a few hiccups on who was featured in what, so I was changing the members) so it might somehow be related, but there's duplicating assets that I haven't messed with yet too.

Also, it should be noted that a 4koma duplicated too, and I just added the KR version of it, as well as adding the members.

db0company commented 5 years ago

If you want to fix yourself, it should be a pretty easy fix.

As a general rule, whenever you see multiple results like this, the solution is to add a .distinct() to the queryset. It happens because a sub query is being performed and that query returns multiple times the same row for each that match the sub query (here, it makes a sub query for all the band members).

So you may ask "why don't we always add it then?", and that's because it makes the query slower which can affect overall performance for all the users. That's why it's better to identify cases where such sub-queries may happen and add a distinct manually.

Now, where to add that distinct? The logic is generally done in the forms, so I would say you should add it in the MagiFilter of the i_band filter (i_band = MagiFilter(..., distinct=True)).

db0company commented 5 years ago

@LatidoReMe It should be solved now, can you check?

LatidoReMe commented 5 years ago

I checked out comics and stamps with it working, so I think it's good!