blakearchive / archive

GNU General Public License v2.0
5 stars 7 forks source link

sorting virtual objects by order they are in in works.csv #507

Closed ghost closed 7 years ago

ghost commented 7 years ago

@nathan-rice

if we were to sort virtual objects in a virtual work by the order they are in in works.csv, how would we do this? i tried removing the order_by line in the following, but i got inconsistent results; the order displayed didn't match up with the order in works.csv:

@staticmethod
    def get_virtual_sorted_query():
        query = models.BlakeObject.query \
            .order_by(models.BlakeObject.butnumber) \
            .filter(models.BlakeObject.supplemental == None)
        return query
nathan-rice commented 7 years ago

It looks like the object_number would work as a new sorting criterion, would it not? Looking at the code, the object_number should correspond to the position in the bad_id field for virtual works.

ghost commented 7 years ago

@nathan-rice hmm, i'm not sure. we want the order of the entries under the column virtual_objects in works.csv to be the order displayed

ghost commented 7 years ago

that way we can manually sort objects in a virtual work

nathan-rice commented 7 years ago

If you look at the import.py script, note that object_number is determined by the order of the objects collection - see here. That objects collection's order is determined by the order of appearance in the virtual_objects field - see here. Thus object_number should do what you want. If it doesn't, you might need to tweak the objects_sorted_for_virtual_copy function slightly to make sure it maintains its input order.

ghost commented 7 years ago

object_number did the trick, thanks. so i guess object_number doesn't correspond to the object number displayed (Object 1, Object 2, etc. on the work info page)