OpenTAXII icon indicating copy to clipboard operation
OpenTAXII copied to clipboard

Update taxii2models.py

Open 1260228859 opened this issue 2 years ago • 1 comments

Here, I need to specify a forced sorting based on the "date_added" field; otherwise, when retrieving data using as_pages(_COLLECTION.get_objects, per_request=limit, added_after=timestamp_filter), I won't be able to obtain all the data.

1260228859 avatar Nov 27 '23 07:11 1260228859

    def _objects_query(self, collection_id: str, ordered: bool) -> Query:
        query = self.db.session.query(taxii2models.STIXObject).filter(
            taxii2models.STIXObject.collection_id == collection_id,
        )
        if ordered:
            query = query.order_by(
                taxii2models.STIXObject.date_added, taxii2models.STIXObject.id
            )
        return query

The previous function is already doing the ordering and it is called by Taxii2SQLDatabaseAPI.get_objects.

Could you elaborate on your use-case and why it is not ordered ?

eric-eclecticiq avatar Nov 11 '25 09:11 eric-eclecticiq