-
Notifications
You must be signed in to change notification settings - Fork 108
Review #7
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
Closed
Review #7
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // callback hell example | ||
| app.get("/details", function (req, res) { | ||
| var name = req.query.name; | ||
| console.log(name); | ||
|
|
||
| Scopus.find({ name: name }, | ||
| { '_id': 0, 'authorId': 1 }, | ||
| function (err, result) { | ||
| if (err) { } | ||
| else { | ||
| var searchResult = result[0]["authorId"]; | ||
| console.log(searchResult); | ||
| var options = { | ||
| url: "https://api.elsevier.com/content/author/author_id/" | ||
| + searchResult + "?apiKey", | ||
| headers: { 'Accept': 'application/json' } | ||
| }; | ||
| request(options, function (error, response, body) { | ||
| if (error) { | ||
|
|
||
| // Print the error if one occurred | ||
| console.error('error in Authors :', error); | ||
|
|
||
| // Print the response status code if a response was received | ||
| console.log('statusCode:', response && response.statusCode); | ||
| res.send("error") | ||
| } | ||
| else if (!error) { | ||
| var jsonObj = JSON.parse(body); | ||
| if (jsonObj['author-retrieval-response'] == undefined) { | ||
| res.send("No details"); | ||
| } | ||
| else { | ||
| var reqData = jsonObj['author-retrieval-response'][0]; | ||
| var authprofile = reqData["author-profile"] | ||
| var names = authprofile["preferred-name"]["indexed-name"] | ||
| console.log(names); | ||
| var citation = reqData["coredata"]["citation-count"]; | ||
| var query = { authorId: searchResult }; | ||
|
|
||
| Scopus.findOneAndUpdate(query, { | ||
| name: names, | ||
| citationCount: citation | ||
| }, function (err, doc, res) { | ||
| if (err) { | ||
| console.log("error"); | ||
| } | ||
| else { | ||
| console.log("success"); | ||
| } | ||
| }) | ||
| res.render("details", { data: reqData }); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| }) | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { useState } from 'react' | ||
| import { Button } from '@mui/material' | ||
| import reactLogo from '@/assets/react.svg' | ||
| import '@/App.css' | ||
|
|
||
| function App() { | ||
| const [count, setCount] = useState(0) | ||
|
|
||
| return ( | ||
| <div className="App"> | ||
| <div> | ||
| <a href="https://vitejs.dev" target="_blank"> | ||
| <img src="/vite.svg" className="logo" alt="Vite logo" /> | ||
| </a> | ||
| <a href="https://reactjs.org" target="_blank"> | ||
| <img src={reactLogo} className="logo react" alt="React logo" /> | ||
| </a> | ||
| </div> | ||
| <h1>Vite + React + Redux + RTK + Rect-router + Typescript + MUI 5</h1> | ||
| <Button color="secondary">Secondary</Button> | ||
| <Button variant="contained" color="success"> | ||
| Success | ||
| </Button> | ||
| <Button variant="outlined" color="error"> | ||
| Error | ||
| </Button> | ||
| <div className="card"> | ||
| <button onClick={() => setCount(count => count + 1)}> | ||
| count is {count} | ||
| </button> | ||
| <p> | ||
| Edit <code>src/App.tsx</code> and save to test HMR | ||
| </p> | ||
| </div> | ||
| <p className="read-the-docs"> | ||
| Click on the Vite and React logos to learn more | ||
| </p> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,51 @@ | ||
| const search = require('./src/client.js') | ||
| const { search, review, refactor } = require('./src/client.js') | ||
| const commands = require('probot-commands-pro') | ||
|
|
||
| module.exports = (app) => { | ||
| commands(app, 'ping', async (context) => { | ||
| const issueComment = context.issue({ | ||
| body: 'pong', | ||
| body: '🤖️: pong', | ||
| }) | ||
| return await context.octokit.issues.createComment(issueComment) | ||
| }) | ||
|
|
||
| app.on(['issues.opened', 'issues.edited'], async (context) => { | ||
| commands(app, 'chatgpt', async (context) => { | ||
| if (context.isBot) | ||
| return | ||
| const { issue } = context.payload | ||
| // if the robot is mentioned in the issue body, reponse with a greeting | ||
| if ( | ||
| issue | ||
| && issue.body | ||
| && issue.body.includes(`/chatgpt`) | ||
| ) { | ||
| const response = await search(issue.body) | ||
| const issueComment = context.issue({ | ||
| body: response, | ||
| }) | ||
| return await context.octokit.issues.createComment(issueComment) | ||
| } | ||
| const { comment, issue, sender } = context.payload | ||
| const { body } = comment || issue | ||
| const prompt = body.replace('/chatgpt', '').trim() | ||
| const response = await search(prompt) | ||
| const issueComment = context.issue({ | ||
| body: `@${sender.login} 🤖️: ${response}`, | ||
| }) | ||
| return await context.octokit.issues.createComment(issueComment) | ||
| }) | ||
| app.on(['issue_comment.created'], async (context) => { | ||
|
|
||
| // WIP: review code from code & add test | ||
| // https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue | ||
| //['issue_comment.created', 'issue_comment.edited', 'issues.opened', 'issues.edited'] | ||
|
|
||
| // configure something | ||
| app.on(['installation'], async (context) => { }) | ||
|
|
||
| app.on(['pull_request_review_comment.created'], async (context) => { | ||
| if (context.isBot) | ||
| return | ||
| const { comment } = context.payload | ||
| // if the robot is mentioned in the issue body, reponse with a greeting | ||
| if ( | ||
| comment | ||
| && comment.body | ||
| && comment.body.includes(`/chatgpt`) | ||
| ) { | ||
| const response = await search(comment.body) | ||
| const issueComment = context.issue({ | ||
| body: response, | ||
| }) | ||
| return await context.octokit.issues.createComment(issueComment) | ||
| const { comment, sender } = context.payload | ||
| const { body, diff_hunk } = comment | ||
| const eventHandlerMap = { | ||
| '/review': review, | ||
| '/refactor': refactor, | ||
| } | ||
| const event = Object.keys(eventHandlerMap).find((key) => body.includes(key)) | ||
| if (!event) return | ||
|
|
||
| const prompt = body.replace(event, '').trim() | ||
| const response = await eventHandlerMap[event]({ prompt, lang: 'javascript', code: diff_hunk }) | ||
| const issueComment = context.issue({ | ||
| body: `@${sender.login} 🤖️: ${response}`, | ||
| }) | ||
| return await context.octokit.issues.createComment(issueComment) | ||
| }) | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.