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

Date filter improvements (#5917) #7196

Merged

Conversation

ad-elias
Copy link
Contributor

Solves issue #5917.

This PR is now ready for the first review!

Filters do not fully work yet, there's a problem applying multiple filters like the following:

{
  and: [
    {
      [correspondingField.name]: {
        gte: start.toISOString(),
      } as DateFilter,
    },
    {
      [correspondingField.name]: {
        lte: end.toISOString(),
      } as DateFilter,
    },
  ],
}

I'll do my best to dig into it tonight!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR implements significant improvements to date filtering functionality, addressing the requirements outlined in issue #5917. Key changes include:

  • Added new date filter operands: 'Is Before', 'Is After', 'Is Relative', 'Is in the past', 'Is in the future', and 'Is today'
  • Introduced RelativeDatePickerHeader component for selecting relative date filters
  • Implemented ViewFilterValueType enum to distinguish between static and variable filter values
  • Enhanced InternalDatePicker to support both absolute and relative date selection
  • Created utility functions for resolving and displaying date filter values

However, there are still issues with applying multiple filters, particularly with the 'and' query where the 'lte' condition is being ignored.

26 file(s) reviewed, 13 comment(s)
Edit PR Review Bot Settings

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work!!! Very cool feature
Some early comments but I didn't do a full review yet

@ad-elias
Copy link
Contributor Author

@FelixMalfait Ready for another review!

@ad-elias Fix tomorrow: selecting a date in 'is' operand and then switching to 'isRelative' operand breaks the filter

@FelixMalfait
Copy link
Member

Really great job! Will start testing and posting feedback.

First one: laybe don't put any default value? Or force taking it into account?
Screenshot 2024-09-26 at 14 06 09
It was a strange experience for me the first time I added that filter it was already filled with "1 Day" but it didn't have any impact, if I wanted to filter on 1 day I would have to remove the value and add it again

type: FieldMetadataType.SELECT,
label: 'Value type',
description: 'View filter value type',
defaultValue: `'${ViewFilterValueType.STATIC}'`,
Copy link
Member

Choose a reason for hiding this comment

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

Strange syntax no? Should it just be defaultValue: ViewFilterValueType.STATIC}? Maybe you did this for a good reason but I don't see why?

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 think the quotes are needed to refer to an enum. Same syntax is used in message-channel-message-association.workspace-entity.ts. I'm not sure but I think without quotes the value would be interpreted as a string, I tried that and it didn't work. The generated table seems correct:

-- Generated by the database client.
CREATE TABLE workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter"(
    id uuid NOT NULL DEFAULT public.uuid_generate_v4(),
    "createdAt" timestamp with time zone NOT NULL DEFAULT now(),
    "updatedAt" timestamp with time zone NOT NULL DEFAULT now(),
    "deletedAt" timestamp with time zone,
    position double precision,
    name text NOT NULL DEFAULT 'Untitled'::text,
    "createdBySource" "viewFilter_createdBySource_enum" NOT NULL DEFAULT 'MANUAL'::"viewFilter_createdBySource_enum",
    "createdByWorkspaceMemberId" uuid,
    "createdByName" text NOT NULL DEFAULT ''::text,
    "displayValue" text NOT NULL DEFAULT ''::text,
    "fieldMetadataId" uuid NOT NULL,
    operand text NOT NULL DEFAULT 'Contains'::text,
    "value" text NOT NULL DEFAULT ''::text,
    "valueType" "viewFilter_valueType_enum" NOT NULL DEFAULT 'STATIC'::"viewFilter_valueType_enum",
    "viewId" uuid,
    PRIMARY KEY(id),
    CONSTRAINT FK_06858adf0fb54ec88fa602198ca FOREIGN key("viewId") REFERENCES view(id)
);
CREATE INDEX IDX_5653b106ee9a9e3d5c1c790419a ON workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter" USING btree ("deletedAt","viewId");
COMMENT ON TABLE workspace_1wgvd1injqtife6y4rvfbu3h5."viewFilter" IS '@graphql({"totalCount": {"enabled": true}})';

Copy link
Member

Choose a reason for hiding this comment

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

OK great

@FelixMalfait
Copy link
Member

  • 1 test that needs to be fixed
Screenshot 2024-09-26 at 15 21 08

@ad-elias
Copy link
Contributor Author

@FelixMalfait I removed the default value and the test is also fixed now!

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work!

@FelixMalfait FelixMalfait merged commit 9d36493 into twentyhq:main Sep 27, 2024
7 of 11 checks passed
Copy link

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID C061:F8FA5:298E9FC:5027D20:66F6BA3B.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aad-elias%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Fri, 27 Sep 2024 13:59:24 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'C061:F8FA5:298E9FC:5027D20:66F6BA3B'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1727445623'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID C061:F8FA5:298E9FC:5027D20:66F6BA3B.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aad-elias%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.4 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-38072d2e.json

Generated by 🚫 dangerJS against 34f8e9b

harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
Solves issue twentyhq#5917.

This PR is now ready for the first review!

Filters do not fully work yet, there's a problem applying multiple
filters like the following:

```
{
  and: [
    {
      [correspondingField.name]: {
        gte: start.toISOString(),
      } as DateFilter,
    },
    {
      [correspondingField.name]: {
        lte: end.toISOString(),
      } as DateFilter,
    },
  ],
}
```

I'll do my best to dig into it tonight!

---------

Co-authored-by: Félix Malfait <[email protected]>
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