Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIN-6002 - Listing templates #1463

Open
wants to merge 9 commits into
base: feature/pin-4901_e-service-template
Choose a base branch
from

Conversation

Carminepo2
Copy link
Contributor

@Carminepo2 Carminepo2 commented Feb 5, 2025

Closes PIN-6002
Merge after #1443

Base automatically changed from pin-6003_get-single-template to feature/pin-4901_e-service-template February 5, 2025 14:59
Comment on lines 125 to 143
$nor: [
{
$and: [
{ "data.creatorId": { $ne: authData.organizationId } },
{ "data.versions": { $size: 0 } },
],
},
{
$and: [
{ "data.creatorId": { $ne: authData.organizationId } },
{ "data.versions": { $size: 1 } },
{
"data.versions.state": {
$eq: eserviceTemplateVersionState.draft,
},
},
],
},
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this filter quite confusing. I'm trying to understand it by reading the SRS and I suppose that this is the filter to remove draft versions if the caller is not the creator. Am I correct? In that case, Couldn't the filter be simplified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I semplified the whole query as such:

{
  $nor: [
    {
      "data.creatorId": { $ne: authData.organizationId },
      "data.versions": { $size: 1 },
      "data.versions.state": eserviceTemplateVersionState.draft,
    },
  ],
}
: {
  $nor: [
    {
      "data.versions": { $size: 1 },
      "data.versions.state": {
        $eq: eserviceTemplateVersionState.draft,
      },
    },
  ],
};

I removed the check for the empty version arra, it could never happed with our actual implementation.
LMK

Copy link
Collaborator

@MalpenZibo MalpenZibo Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused. Why are you using nor with only one expression inside?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong but I think that's the only way to have a "$not" operator at that level on documentDB

@Carminepo2 Carminepo2 requested a review from MalpenZibo February 6, 2025 09:59
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