-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Providing score trend on plugins enhancement #495
base: main
Are you sure you want to change the base?
Conversation
Hello @AayushSaini101 Thank you for starting this Draft PR. Don't forget to explain in the description the "what", the "why", the "what-for", etc. Take the time to explain the PR to the maintainer in details. Another useful thing to do before pushing a commit/pr is to verify that it builds locally. Obviously the checkstyle fails. Or if using TDD and first pushing a failing test, explain it. |
Please note, again, that there is a pull request template which is here to help you format what you contribute. |
Thanks @jmMeessen :) Done |
I fixed the description. Please, the "previous score" shouldn't be in the "plugin". You are not starting correctly. |
I will use that value [-1,0,1] means score change, score don't change, score increased that is stored in the column of the table, and according to the value present for individual plugin, we can show the message whether the score is decreased or not. what you think @alecharp |
We already keep the last 5 scores in the scores table. Don't duplicate entries like that. |
@alecharp Thanks, i checked the table but cannot able to find the last score list of a plugin, can you help where it is present, |
If you run the scoring multiple times, you will see that you have multiple entries for the same |
Thanks, Yes there are multiple entries of a plugin, So the maximum duplicates of a single plugin_id can be 5. |
Rather than just knowning if it increases or decreases, I think it's preferable to know the score. This way, the UI can decide if its shows the value or if it shows a sign for the trend. This would have been a great discussion on the issue, to understand the prerequisite of the work to be done, rather than here on a pull request. |
Sure @alecharp I am moving the discussion on the issue |
49a1411
to
04efbb3
Compare
Testing changes only for verification@alecharp I tried to add previous from one approach, I am making single db call, but the score will contains at max 2 duplicate score records, this will change the ScoreStatistics values, Is it good ? Or we can make separate db call for the requirement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forced push this pull request, again.
Now we can see changes that were done in the main
branch as part of this pull request.
Lots of files were changed that are not related to this pull request.
Statistics should not be changed because you creates. They should only be about the latest scores.
.DS_Store
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
Jenkinsfile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
war/.yarnrc.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
war/yarn.lock
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved @alecharp
@alecharp Sorry these are not completed changes, i was just checking whether the approaches and changes can be used or not. This will not happen again :) One Question; can we make two db call in this case? one for latest score and one for previous score in the same endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a test using different score and previous score for at least 2 plugins because the current test is not testing that.
Added new test case for verifying the previousScore @alecharp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the getLatestScoresSummaryMap
and getPreviousScoreMap
method need a list of Score
in input.
public Map<String, Score> getLatestScoresSummaryMap() { | ||
return repository.findLatestScoreForAllPlugins().stream() | ||
.collect(Collectors.toMap( | ||
score -> score.getPlugin().getName(), | ||
score -> score | ||
)); | ||
public Map<String, Score> getLatestScoresSummaryMap(List<Score> scores) { | ||
return scores.stream() | ||
.collect(Collectors.toMap( | ||
score -> score.getPlugin().getName(), | ||
score -> score, | ||
(existingScore, newScore) -> existingScore)); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public Map<String, Long> getPreviousScoreMap(List<Score> scores) { | ||
return scores.stream() | ||
.collect(Collectors.toMap( | ||
score -> score.getPlugin().getName(), // Key mapper | ||
Score::getValue, // Value mapper | ||
(existingValue, newValue) -> newValue // Merge function | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the methods have a parameter.
Those methods don't use the database at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alecharp I created this findLastTwoScoreForAllPlugins method to fetch last two score for all plugins, and these methods getLatestScoresSummaryMap and getPreviousScoreMap are used to find the last and last second score of a plugin, These methods takes the output generated by indLastTwoScoreForAllPlugins() method. @Transcation annotation need to removed i checked now thanks
List<Score> scoreList = new ArrayList<>(); | ||
scoreList.add(p1s); | ||
scoreList.add(p2s); | ||
scoreList.add(p2sOld); | ||
scoreList.add(p1sOld); | ||
scoreList.add(p1sOld2); | ||
|
||
final Map<String, Score> summary = scoreService.getLatestScoresSummaryMap(scoreList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows that we need to provide the scores we want to see to the method, when those scores are in fact in the database.
The method makes no sense to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alecharp updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alecharp updated
100, 1, List.of("There is no active security advisory for the plugin."))), | ||
1)); | ||
|
||
final ZonedDateTime latestTimePlugin2 = ZonedDateTime.now().minusMinutes(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alecharp removed
scoreP1Date.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME), | ||
scoreP1Date.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)), | ||
false)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reactivate the formatter before closing the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alecharp Cannot format manually once I edit the file, spotless causing build failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add // @formatter:on
before the end of the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @alecharp
@alecharp I guess, i have answered and resolved all your comments |
I don't know I have to check. Please see to fill the pull request description first. |
Done @alecharp |
There is still a TODO in the pull request description @AayushSaini101 |
Added more points @alecharp thanks |
And still, there is a TODO |
In fact, no. It's important to add the testing that you have done for this pull request, this is why it's in the pull request template. Removing that section is not the way to go, it needs to be filled. |
@alecharp I guess now it is correct |
Have you tested you code and its behavior? |
@alecharp Yes i have tested this, and also pasted the screenshoot in the comment #495 (comment) weird, migth be due to new changes in master branch causing no output. I will check |
@AayushSaini101 do you think you will be able to complete this pull request? |
Sorry @alecharp I was on the vacations. I can start working in the next week |
Description
Add a new field in the HTTP API that helps to analyze the evolution of the plugin's score.
Task :
Closes #493.
Testing Done
Submitter checklist