zhaoyongjie commented on a change in pull request #12793:
URL: https://github.com/apache/superset/pull/12793#discussion_r565779827



##########
File path: 
superset-frontend/src/explore/components/controls/DateFilterControl/utils.ts
##########
@@ -183,31 +197,27 @@ export const customTimeRangeEncode = (customRange: 
CustomRangeType): string => {
   } = { ...customRange };
   // specific : specific
   if (SPECIFIC_MODE.includes(sinceMode) && SPECIFIC_MODE.includes(untilMode)) {
-    const since = sinceMode === 'specific' ? sinceDatetime : sinceMode;
-    const until = untilMode === 'specific' ? untilDatetime : untilMode;
+    const since = sinceMode === 'specific' ? dttmToString(sinceDatetime) : 
sinceMode; // eslint-disable-line

Review comment:
       glad to follow to linting rules and make the change, however, I still 
believe breaking the lines is unnecessary. It makes it harder to read this 
code, especially in the case where we want to compare since and until side by 
side.
   
   but I am still willing to follow everyone's conventions. 
   
   ###  ⇓ disable linting
   ```
   ...
     // specific : specific
     if (SPECIFIC_MODE.includes(sinceMode) && 
SPECIFIC_MODE.includes(untilMode)) {
       const since = sinceMode === 'specific' ? dttmToString(sinceDatetime) : 
sinceMode; // eslint-disable-line
       const until = untilMode === 'specific' ? dttmToString(untilDatetime) : 
untilMode; // eslint-disable-line
       return `${since} : ${until}`;
     }
   
     // specific : relative
     if (SPECIFIC_MODE.includes(sinceMode) && untilMode === 'relative') {
       const since = sinceMode === 'specific' ? dttmToString(sinceDatetime) : 
sinceMode; // eslint-disable-line
       const until = `DATEADD(DATETIME("${since}"), ${untilGrainValue}, 
${untilGrain})`; // eslint-disable-line
       return `${since} : ${until}`;
     }
   
     // relative : specific
     if (sinceMode === 'relative' && SPECIFIC_MODE.includes(untilMode)) {
       const until = untilMode === 'specific' ? dttmToString(untilDatetime) : 
untilMode; // eslint-disable-line
       const since = `DATEADD(DATETIME("${until}"), 
${-Math.abs(sinceGrainValue)}, ${sinceGrain})`; // eslint-disable-line
       return `${since} : ${until}`;
     }
   
     // relative : relative
     const since = `DATEADD(DATETIME("${anchorValue}"), 
${-Math.abs(sinceGrainValue)}, ${sinceGrain})`; // eslint-disable-line
     const until = `DATEADD(DATETIME("${anchorValue}"), ${untilGrainValue}, 
${untilGrain})`;
     return `${since} : ${until}`;
   ...
   ```
   
   ### ⇓ enable linting
   ```
   ...
     // specific : specific
     if (SPECIFIC_MODE.includes(sinceMode) && 
SPECIFIC_MODE.includes(untilMode)) {
       const since =
         sinceMode === 'specific' ? dttmToString(sinceDatetime) : sinceMode;
       const until =
         untilMode === 'specific' ? dttmToString(untilDatetime) : untilMode;
       return `${since} : ${until}`;
     }
   
     // specific : relative
     if (SPECIFIC_MODE.includes(sinceMode) && untilMode === 'relative') {
       const since =
         sinceMode === 'specific' ? dttmToString(sinceDatetime) : sinceMode;
       const until = `DATEADD(DATETIME("${since}"), ${untilGrainValue}, 
${untilGrain})`;
       return `${since} : ${until}`;
     }
   
     // relative : specific
     if (sinceMode === 'relative' && SPECIFIC_MODE.includes(untilMode)) {
       const until =
         untilMode === 'specific' ? dttmToString(untilDatetime) : untilMode;
       const since = `DATEADD(DATETIME("${until}"), ${-Math.abs(
         sinceGrainValue,
       )}, ${sinceGrain})`;
       return `${since} : ${until}`;
     }
   
     // relative : relative
     const since = `DATEADD(DATETIME("${anchorValue}"), ${-Math.abs(
       sinceGrainValue,
     )}, ${sinceGrain})`;
     const until = `DATEADD(DATETIME("${anchorValue}"), ${untilGrainValue}, 
${untilGrain})`;
     return `${since} : ${until}`;
   ...
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to