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

fix: run playbook job with no variable #4453

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

fit2bot
Copy link
Contributor

@fit2bot fit2bot commented Nov 21, 2024

fix: run playbook job with no variable

@fit2bot fit2bot requested a review from a team November 21, 2024 14:05
@@ -99,6 +99,7 @@ export default {
data?.variable.map(item => {
delete item.job
delete item.playbook
delete item.id
return item
})
updateForm({ variable: data.variable })

Choose a reason for hiding this comment

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

There are no obvious issues in the provided code snippet. However, to further optimize this process of deleting specific variables that don't have 'job' and 'playbook' properties from a JSON array:

  1. First, it's better practice to separate functions if necessary.
  2. Also consider using Object.entries instead of an explicit loop when accessing keys like id.

Example optimized code with these improvements (keeping things simple):

export default function UpdateData(data) {
   // assuming data is a variable containing objects like [{variable},{another_variable},{....}]
   return new Promise((resolve, reject) => {
      const updatedArray = [];
     // Loop through each object in the dataset 
        for(const [key,i] of Object.entries(...data)){
           let variableObj = {...data[key]};
            delete variableObj.job;
            delete variableObj.playbook;            
            deletedId.push(key); 

         // Add back only the variable with 'id' property which has not been modified already

          // Assuming some key will always be present
       var tempId = i + "temp";
       updatedArray[i]= {key:tempId,...variableObj};   
    resolve(updatedArray);
}
 }

If your context requires more specific advice based on other components or external requirements, please specify.

@BaiJiangJie BaiJiangJie merged commit fcdd090 into v4.4 Nov 21, 2024
3 of 4 checks passed
@BaiJiangJie BaiJiangJie deleted the pr@v4.4@fix_run_playbook_job branch November 21, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants