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

Add option to restart jobs upon comment submission #5946

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

b10n1k
Copy link
Contributor

@b10n1k b10n1k commented Sep 25, 2024

This commit enhances the comment submission functionality with an integrated job restart option, improving workflow efficiency for users managing multiple jobs.

For this restart_job helper added in Helpers.pm and _restart in Job.pm had to be refactored to encapsulate the logic and the reusability of the feature(restart_jobs) in multiple places within the application.

https://progress.opensuse.org/issues/166559

assets/javascripts/overview.js Outdated Show resolved Hide resolved
lib/OpenQA/WebAPI/Controller/API/V1/Comment.pm Outdated Show resolved Hide resolved
<input class="form-check-input"
type="checkbox" value="" id="wannaRestartCheck">
<label class="form-check-label" for="wannaRestartCheck">
Restart on Submit
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Restart on Submit
Also restart job(s) on submit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I avoid also? Restart job(s) on submit sound sufficient, no?

Copy link
Member

Choose a reason for hiding this comment

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

I see the "also" as necessary to make it clear that the checkbox wouldn't "restart instead of commenting" but "restart and comment". But after the discussion we just had I suggest to actually have two buttons:

  1. Left, less-alerting button for "comment", e.g. in light orange
  2. Right, more-alerting button for "Comment and restart", e.g. the current red color

This commit enhances the comment submission functionality with an integrated
job restart option, improving workflow efficiency for users managing multiple
jobs.

For this `restart_job` helper added in `Helpers.pm` and `_restart` in `Job.pm`
had to be refactored to encapsulate the logic and the reusability of the
feature(restart_jobs) in multiple places within the application.

https://progress.opensuse.org/issues/166559

Signed-off-by: Ioannis Bonatakis <[email protected]>
@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 25, 2024

for the sake of completeness and avoid any confusion I fixed the issue with the test and some requests from feedback. But I flag the PR as invalid

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 86.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 98.71%. Comparing base (e88bdd3) to head (2c24af9).
Report is 279 commits behind head on master.

Files with missing lines Patch % Lines
lib/OpenQA/WebAPI/Controller/API/V1/Comment.pm 46.15% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5946      +/-   ##
==========================================
- Coverage   98.73%   98.71%   -0.03%     
==========================================
  Files         395      395              
  Lines       38764    38782      +18     
==========================================
+ Hits        38275    38282       +7     
- Misses        489      500      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

my ($res, $jobs, $auto, $single_job_id, $dup_route);
my %args = (jobs => $job_id);
$self->param('jobid', $job_id);
eval { ($res, $jobs, $auto, $single_job_id, $dup_route) = $self->restart_job(\%args); };
Copy link
Contributor

Choose a reason for hiding this comment

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

The _restart method already supports multiple jobs as parameters.
The documentation for the /restart route says "Restart job(s)."

Calling this for every single job and validating the same request parameters again and again is not necessary.
Also you are passing something in %args but you never read that in the function.

And there is already one function that restarts one job, that could also be called, instead of calling the whole _restart thing:

my $res = OpenQA::Resource::Jobs::job_restart($jobs, @params);

Copy link
Contributor

Choose a reason for hiding this comment

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

@Martchus and that's actually also what I meant earlier today: _restart is a complete endpoint:

sub restart ($self) { $self->_restart }

making a helper that implements a complete endpoint, doesn't make much sense to me.

Copy link
Contributor

mergify bot commented Sep 30, 2024

This pull request is now in conflicts. Could you fix it? 🙏

@kalikiana
Copy link
Member

kalikiana commented Oct 17, 2024

Obsoleted by #5971 I guess?

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.

4 participants