-
Notifications
You must be signed in to change notification settings - Fork 3
Quick options #23
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
Open
atuannguyen1101
wants to merge
6
commits into
master
Choose a base branch
from
quickOptions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Quick options #23
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
27a12c3
Setting up DB
atuannguyen1101 6eb1be6
Popular Team
atuannguyen1101 5f61b15
Optimizes Quick options for Teams and Players
atuannguyen1101 3add5df
Fix Reminder
atuannguyen1101 842d32e
Cleaner log
atuannguyen1101 2f46001
Bring updateDB out of listen
atuannguyen1101 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 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
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 |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ function teamNameLookup(sender_psid, key) { | |
| if (teamName.key.includes(key)) { | ||
| flag = false; | ||
| handleCases.teamOptions(sender_psid, teamName.val().name, teamName.val().imageURL); | ||
|
|
||
| // Increase the number of search on the match. | ||
| updateDB.popularTeam(teamName.val().name); | ||
| } | ||
| }) | ||
| }); | ||
|
|
@@ -39,6 +42,12 @@ function teamNameLookup(sender_psid, key) { | |
| "text" : `Cannot find the Team: ${key}` | ||
| } | ||
| sendResponse.directMessage(sender_psid, response); | ||
| setTimeout(() => { | ||
| handleCases.popularTeam(sender_psid); | ||
| }, 1000) | ||
| console.log("Error occured on Server for TEAM: " + key); | ||
| console.error(err); | ||
| console.error("\n\n") | ||
| } | ||
| else { | ||
| flag = false; | ||
|
|
@@ -55,6 +64,10 @@ function teamNameLookup(sender_psid, key) { | |
| 'name': teamName, | ||
| 'imageURL': imageURL | ||
| }); | ||
|
|
||
| // Increase the number of search on the match. | ||
| updateDB.popularTeam(teamName); | ||
|
|
||
| handleCases.teamOptions(sender_psid, teamName, imageURL); | ||
| } | ||
| }) | ||
|
|
@@ -141,6 +154,9 @@ function matchLookup(sender_psid, key, status) { | |
| "text" : `Cannot find the Match for: ${key}` | ||
| } | ||
| sendResponse.directMessage(sender_psid, response); | ||
| console.log("Error occured on Server for MATCH: " + key); | ||
| console.error(err); | ||
| console.error("\n\n") | ||
| } | ||
| else { | ||
| request({ | ||
|
|
@@ -214,14 +230,29 @@ function playerLookup(sender_psid, key) { | |
|
|
||
| // Checks if the player is already in database | ||
| db.ref('Players/').once("value", (allPlayers) => { | ||
| allPlayers.forEach((eachPlayer) => { | ||
| if (eachPlayer.key.includes(key)) { | ||
| flag = false; | ||
| sendResponse.playerReply(sender_psid, eachPlayer.val().playerTitle, | ||
| eachPlayer.val().playerSubtitle, eachPlayer.val().playerImageURL, | ||
| eachPlayer.val().playerURL); | ||
| } | ||
| }) | ||
|
|
||
| // Act as loop's break | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sao ko xài loop break bthg
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Xài forEach không hỗ trợ break |
||
| try { | ||
| allPlayers.forEach((eachPlayer) => { | ||
| if (eachPlayer.key.includes(key)) { | ||
| flag = false; | ||
|
|
||
| // Increase the number of search on the player. | ||
| var playerName = eachPlayer.val().playerTitle; | ||
| playerName = playerName.slice(0, playerName.indexOf("-") - 1); | ||
|
|
||
| updateDB.popularPlayer(playerName); | ||
|
|
||
| sendResponse.playerReply(sender_psid, eachPlayer.val().playerTitle, | ||
| eachPlayer.val().playerSubtitle, eachPlayer.val().playerImageURL, | ||
| eachPlayer.val().playerURL); | ||
|
|
||
| throw BreakException; | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| catch (e) {} | ||
| }) | ||
|
|
||
| // If the player is not in the database, search for him | ||
|
|
@@ -242,12 +273,15 @@ function playerLookup(sender_psid, key) { | |
| 'text' : `Cannot find player: ${key}` | ||
| }; | ||
| sendResponse.directMessage(sender_psid, response); | ||
| setTimeout(() => { | ||
| handleCases.popularPlayer(sender_psid); | ||
| }, 1000) | ||
| } | ||
| else { | ||
| flag = false; | ||
| let playerImageURL = reply[0]; | ||
| let playerURL = reply[1]; | ||
| let eachPlayer = reply[2]; | ||
| let playerName = reply[2]; | ||
| let playerTitle = reply[2] + ' - ' + reply[3]; | ||
| let playerSubtitle = reply[4]; | ||
| for (var eachData = 5; eachData < 7; eachData++) { | ||
|
|
@@ -266,14 +300,15 @@ function playerLookup(sender_psid, key) { | |
| } | ||
|
|
||
| // Save search result to database | ||
| db.ref('Players/' + dataFormat.cleanKeyDB(eachPlayer).toUpperCase() + '/').set({ | ||
| db.ref('Players/' + dataFormat.cleanKeyDB(playerName).toUpperCase() + '/').set({ | ||
| 'playerURL': playerURL, | ||
| 'playerTitle': playerTitle, | ||
| 'playerSubtitle': playerSubtitle, | ||
| 'playerImageURL': playerImageURL | ||
| }); | ||
|
|
||
|
|
||
| // Increase the number of search on the player. | ||
| updateDB.popularPlayer(playerName); | ||
|
|
||
| console.log("replied"); | ||
| sendResponse.playerReply(sender_psid, playerTitle, playerSubtitle, playerImageURL, playerURL); | ||
|
|
||
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
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.
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.
mấy cái function này set timeout chi
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.
Cho nó delay 1 tí thay vì send 2 tin liên tục, dễ bị tin này đè tin kia