Skip to content

Conversation

@1260228859
Copy link

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.

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.
@eric-eclecticiq
Copy link
Contributor

    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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants