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

Store user feedback in db #798

Merged
merged 8 commits into from
May 19, 2023
Merged

Conversation

afifaniks
Copy link
Contributor

This patch collects and stores user feedback on a collection upon feedback button clicks

Fixes: #496

Signed-off-by: Afif Al Mamun afifanik@gmail.com

This patch collects and stores user feedback on a collection upon feedback button clicks

Fixes: 496
Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
@netlify
Copy link

netlify bot commented Apr 18, 2023

Deploy Preview for eclipsefdn-adoptium-trss canceled.

Name Link
🔨 Latest commit 1cf855b
🔍 Latest deploy log https://app.netlify.com/sites/eclipsefdn-adoptium-trss/deploys/64565ba06348a5000771e49a

@llxia
Copy link
Contributor

llxia commented Apr 20, 2023

@afifaniks Could you resolve the merge conflicts? Thanks

Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
@afifaniks
Copy link
Contributor Author

@llxia merge conflicts have been resolved.

@llxia
Copy link
Contributor

llxia commented Apr 20, 2023

Is this PR ready for review? If so, please move it out of the draft. Thanks

@afifaniks afifaniks marked this pull request as ready for review April 20, 2023 13:07
Copy link
Contributor

@karianna karianna left a comment

Choose a reason for hiding this comment

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

I've not reviewed carefully, but are we santitizing input here?

@afifaniks
Copy link
Contributor Author

@karianna Hi. There is no "dynamic" user input that we are storing for the time being. Do we still need sanitization for the data we are storing? Thanks.

@karianna
Copy link
Contributor

I think we're OK as long as someone can't hit that end point using CURL or other HTTP libs to send in whatever they like :-)

@afifaniks afifaniks closed this Apr 21, 2023
@afifaniks afifaniks reopened this Apr 21, 2023
@afifaniks
Copy link
Contributor Author

afifaniks commented Apr 21, 2023

Hello @llxia @LongyuZhang, looks like we have an issue with the file name. Any recommendation on file name generation? We may also try implementing the recommendations given here: https://codeql.github.com/codeql-query-help/go/go-path-injection/

@llxia
Copy link
Contributor

llxia commented Apr 21, 2023

@afifaniks This is a false alarm. We do not allow users to define any file path/name. The file path/name is pre-defined/hardcoded. To avoid the false alarm in the future, please put the output filename generate code within writeTestOutputToFile(). Hopefully, the code scan can understand it better.

Also, we should not store the output whenever feedback is provided. We need to check if the output file exists or not first. Only store the output on disk if the file does not exist.

@LongyuZhang On a related note, we are planning to run TRSS via docker. If we do, the files will be lost if we turn off the container unless the volume is used.

Copy link
Contributor

@LongyuZhang LongyuZhang left a comment

Choose a reason for hiding this comment

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

Besides checking if the output file exists or not first, we could also accumulate the user feedback for a particular issue, e.g. positive feedback 3 times, negative 2 times. So in the DB, we may need to save positive and negative feedback separately.

Regarding the docker folder, I think we can replace the file folder into the volume once starting running TRSS in docker.

@afifaniks
Copy link
Contributor Author

@llxia @LongyuZhang have we decided on the new additions we are talking about? If yes, then I can start working on them. Thanks.

@llxia
Copy link
Contributor

llxia commented Apr 24, 2023

@afifaniks 3 action items from the above comments:

Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
@afifaniks
Copy link
Contributor Author

afifaniks commented Apr 25, 2023

@llxia As we are now considering keeping counters of positive and negative feedback, do we need the "accuracy" field in the database anymore? We can simply update the existing counter of a record each time feedback is provided, right?
Additionally, do you have any design in mind that I may work on to show the count on UI?

Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
@afifaniks
Copy link
Contributor Author

@llxia I have made some changes to store positive and negative counters with the aforementioned approach. Please have a look if it would justify the requirement. Thanks.

const fileName = `${testName}_${buildName}_${buildNum}_${domain}.txt`;
const outputPath = `${__dirname}/../../MachineLearningPrototype/data/JenkinsDataWithFeedback/${fileName}`;

const fileExists = await fs.stat(outputPath).then(

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
);

if (!fileExists) {
await fs.writeFile(outputPath, testOutput);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
@llxia
Copy link
Contributor

llxia commented Apr 26, 2023

@afifaniks Thanks for the update.

do we need the "accuracy" field in the database anymore? We can simply update the existing counter of a record each time feedback is provided, right? Additionally, do you have any design in mind that I may work on to show the count on UI?

Yes, that is correct. We do not need the "accuracy" field anymore. It can be removed. We should display the counter in UI. For example, 5 positive feedback and 2 negative feedback:

👍 5 👎 2

The UI update can be in a separate PR.

We still have Uncontrolled data used in path expression error. I think we can merge this PR and fix it later by using an off-the-shelf library like the sanitize-filename npm package. Please open an issue to track this.

@afifaniks
Copy link
Contributor Author

@llxia the issue has been created.

Copy link
Contributor

@LongyuZhang LongyuZhang left a comment

Choose a reason for hiding this comment

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

LGTM

@llxia
Copy link
Contributor

llxia commented Apr 28, 2023

@afifaniks if you plan to remove accuracy in another PR, please open an issue to track it.

@LongyuZhang
Copy link
Contributor

The separate issue to remove accuracy has been created here #800

@afifaniks
Copy link
Contributor Author

@llxia accuracy field is already removed in this PR. We are not writing this field in the database rather the value of the request parameter "accuracy" determines whether it is positive feedback or negative; i.e. 0 = negative, 1 = positive. That being said, do we want to remove the accuracy field from the request body?

const fileName = `${testName}_${buildName}_${buildNum}_${domain}.txt`;
const outputPath = `${__dirname}/../../MachineLearningPrototype/data/JenkinsDataWithFeedback/${fileName}`;

const fileExists = await fs.stat(outputPath).then(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While stat() is providing us with an asynchronous way to check if the file exists or not, shall we move to a blocking method?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we should use existsSync(). In asynchronous, the file could be deleted after the check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

await insertNewFeedback(db, req.body);
} else {
await updateFeedback(db, record, accuracy);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use upsert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @llxia, if we want to upsert we may have to query for the testOutput regardless of whether it's an insert or update operation. Branching them based on the record's existence may save us one separate database query. Although I have already implemented upsert on my local branch I thought I should ask what you think about this. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

In upsert, we should be able to know to insert or update based on the return value.
testOutput is needed if the file does not exist on disk. Having the record in db does not mean that the testOutput is stored on disk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm, I think I am missing something here. Are you talking to replace updateFeedback() with an upsert operation? What I inferred last time is to remove the check for the record's existence [getRecordIfExists()] and directly upsert the input rather than using two methods (insertNewFeedback, updateFeedback).

@llxia
Copy link
Contributor

llxia commented Apr 28, 2023

With the positive feedback counter and negative feedback counter, we do not need accuracy at all.

Signed-off-by: Afif Al Mamun <afifanik@gmail.com>
@llxia
Copy link
Contributor

llxia commented May 19, 2023

Sorry @afifaniks , I was busy with the release. I think we can merge this PR for now. We can make the enhancements in the future PR.

@llxia llxia merged commit 6fda215 into adoptium:master May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collect user feedback for Deep AQAtik predictions
4 participants