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

Add support for 'group' and 'having' keys in smart filters #1286

Merged

Conversation

Dr-Blank
Copy link
Contributor

@Dr-Blank Dr-Blank commented Nov 6, 2023

SmartFilterMixin

Description

excludes keys not belonging to smart filter

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

@Dr-Blank Dr-Blank changed the title Add support for 'group' and 'having' keys in Add support for 'group' and 'having' keys in smart filters Nov 6, 2023
@JonnyWong16
Copy link
Collaborator

JonnyWong16 commented Nov 6, 2023

I was just looking into how to allow group and having in the search filters as well. We can just add them as manual fields here:

additionalFields = [
('guid', 'guid', 'Guid'),
('id', 'integer', 'Rating Key'),
('index', 'integer', f'{self.type.capitalize()} Number'),
('lastRatedAt', 'date', f'{self.type.capitalize()} Last Rated'),
('updatedAt', 'date', 'Date Updated')
]

        additionalFields = [
            ('guid', 'guid', 'Guid'),
            ('id', 'integer', 'Rating Key'),
            ('index', 'integer', f'{self.type.capitalize()} Number'),
            ('lastRatedAt', 'date', f'{self.type.capitalize()} Last Rated'),
            ('updatedAt', 'date', 'Date Updated'),
            ('group', 'string', 'SQL Group By Statement'),
            ('having', 'string', 'SQL Having Clause')
        ]

group and having should not have the prefix prepended.

for field, fieldType, fieldTitle in additionalFields:
fieldXML = (
f'<Field key="{prefix}{field}" '
f'title="{fieldTitle}" '
f'type="{fieldType}"/>'
)

        for field, fieldType, fieldTitle in additionalFields:
            if field not in {'group', 'having'}:
                field = f"{prefix}{field}"
            fieldXML = (
                f'<Field key="{field}" '
                f'title="{fieldTitle}" '
                f'type="{fieldType}"/>'
            )

This should allow passing the parsed filters back into search().

…ingType` class

- This should allow passing the parsed filters back into `search()`.

Co-Authored-By: JonnyWong16 <[email protected]>
@Dr-Blank Dr-Blank marked this pull request as ready for review November 7, 2023 23:36
@JonnyWong16 JonnyWong16 merged commit 4924320 into pkkid:master Nov 13, 2023
5 checks passed
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.

Filter parsing returns unknown keys group and having
2 participants