sil-ai / aqua-api

API for Augmented Quality Assessment
MIT License
3 stars 0 forks source link

Update assessment permission/aqua229 #351

Closed alejandroaquintero closed 2 months ago

alejandroaquintero commented 2 months ago

Assessment permission:

Now permission to /GET an assessment will be given if:

The latter is achieved using this select clause in sql alchemy:

stmt = (
            select(Assessment)
            .join(BibleRevision, BibleRevision.id == Assessment.revision_id)
            .outerjoin(ReferenceRevision, ReferenceRevision.id == Assessment.reference_id)
            .filter(
                BibleRevision.bible_version_id.in_(version_ids),
                or_(
                    Assessment.reference_id == None,
                    ReferenceRevision.bible_version_id.in_(version_ids),
                )
            )
        )

Here you make a join with revision.id that we now exists, we check if the version id of that revision is on the list of versionids accessible by the user, and other join(outer) with the reference revision(also revision table but with alias), with the or clause we say, either the reference_id is null(we don't have to check anything), and if not, we have to check that the version id is in our version_ids list.

Additionally, we removed the assessment access table since we won't be using it anymore. Also had to make some changes on alembic because the async operations were causing a bit of trouble, so basically, we configured it to work async

alejandroaquintero commented 2 months ago

easily roll back?

Yes it should be fairly easy to rollback, as we are going to delete the assessment table, we could roll back the db with alembic, but in any case, I am going to take a snapshot. And we can test it first on our dev runner to see if it works well

woodwardmw commented 2 months ago

easily roll back?

Yes it should be fairly easy to rollback, as we are going to delete the assessment table, we could roll back the db with alembic, but in any case, I am going to take a snapshot. And we can test it first on our dev runner to see if it works well

Great. I think you can go ahead and merge when you're ready then.