dosubot[bot] commented on issue #29968:
URL: https://github.com/apache/superset/issues/29968#issuecomment-2296363111

   <!-- Answer -->
   To set the `refresh_frequency` to a CRON expression like `"0 3 * * *"` in 
the JSON Metadata without causing an error, you need to ensure that the 
`refreshFrequency` variable in the `saveDashboard` method is set to the desired 
CRON expression.
   
   Here's the relevant part of the code where you can set the 
`refresh_frequency`:
   
   ```tsx
   saveDashboard() {
       const { saveType, newDashName } = this.state;
       const {
         dashboardTitle,
         dashboardInfo,
         layout: positions,
         customCss,
         dashboardId,
         refreshFrequency: currentRefreshFrequency,
         shouldPersistRefreshFrequency,
         lastModifiedTime,
       } = this.props;
   
       // Set the refresh frequency to the desired CRON expression
       const refreshFrequency = shouldPersistRefreshFrequency
         ? currentRefreshFrequency
         : "0 3 * * *"; // Set your CRON expression here
   
       const data = {
         certified_by: dashboardInfo.certified_by,
         certification_details: dashboardInfo.certification_details,
         css: customCss,
         dashboard_title:
           saveType === SAVE_TYPE_NEWDASHBOARD ? newDashName : dashboardTitle,
         duplicate_slices: this.state.duplicateSlices,
         last_modified_time: lastModifiedTime,
         owners: dashboardInfo.owners,
         roles: dashboardInfo.roles,
         metadata: {
           ...dashboardInfo?.metadata,
           positions,
           refresh_frequency: refreshFrequency,
         },
       };
   
       if (saveType === SAVE_TYPE_NEWDASHBOARD && !newDashName) {
         this.props.addDangerToast(
           t('You must pick a name for the new dashboard'),
         );
       } else {
         this.onSave(data, dashboardId, saveType).then((resp: JsonResponse) => {
           if (saveType === SAVE_TYPE_NEWDASHBOARD && resp.json?.result?.id) {
             window.location.href = 
`/superset/dashboard/${resp.json.result.id}/`;
           }
         });
         this.modal?.current?.close?.();
       }
     }
   ```
   
   By setting the `refreshFrequency` variable to the CRON expression `"0 3 * * 
*"`, you ensure that the `refresh_frequency` in the metadata is correctly set 
without causing an error. Additionally, ensure that the CRON expression adheres 
to the format and constraints specified in the Superset documentation, such as 
a maximum length of 1000 characters and a minimum length of 1 character 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/SaveModal.tsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/docs/static/resources/openapi.json)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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.

To unsubscribe, e-mail: [email protected]

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