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

Filters for date and datetime to search by week #2965

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bandtank
Copy link
Contributor

This request adds a few filters to date and datetime fields:

  • Current Week - search for records within the current week (based on the user's weekStart preference or the system's weekStart setting if the user does not have a preference)
  • Last Week - Look for records in the last full week (the current week is not searched)
  • Last X Weeks - Look for records in the last X full weeks (the current week is not searched)
  • Next Week - Look for records in the next full week (the current week is not searched)
  • Next X Weeks - Look for records in the next X full weeks (the current week is not searched)

Many businesses operate on a weekly basis, which makes searching, reporting, and filtering records with weekly filters very attractive. I currently build these filters into my instances manually. Instead of continuing to do that, I took the time to add the features to the application in a (hopefully) maintainable way.

If you do not like this feature or some of the changes, please let me know if there is anything I could change for it to be accepted. Otherwise, I will probably release the features as an extension, presuming I can figure how to do that.

image

image

@bandtank
Copy link
Contributor Author

bandtank commented Jan 28, 2024

#2284

I figured out how to run the tests. Sorry for all the noise. I will debug and iterate locally now.

@yurikuzn
Copy link
Contributor

yurikuzn commented Jan 28, 2024

Hi,

This raise some design issues. It was supposed that the Converter class is user agnostic. I'll consider this enhancement when get a chance, maybe will re-implement, not sure.

To add filters in a module:

@bandtank
Copy link
Contributor Author

bandtank commented Jan 28, 2024

Ok, sounds good. I thought about adding the feature in a module, but I couldn't figure out how to work around DateTimeTransformer. I'll see if I can figure something out. Thanks

@yurikuzn
Copy link
Contributor

See https://github.com/espocrm/espocrm/blob/8.1.1/application/Espo/Core/Select/Where/ConverterFactory.php#L150. As an option, you can have this filters only for date view.

@yurikuzn
Copy link
Contributor

You can also by pass the date-time transformer and rely only on where item converter for both date-times and dates. I think this would be the easiest and future-proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants