Superalgos Network: Events Query implemented. Deep Scan Bug Fixed #2
This commit is contained in:
1 parent
72cf70617d
commit
f997021c0d
5 files changed
+68
-12
No files matched your search
@@ -211,6 +211,7 @@ exports.newGithubServer = function newGithubServer() {
|
||||
})
|
||||
await getPrList()
|
||||
await mergePrs()
|
||||
await closePrsToMaster()
|
||||
|
||||
async function getPrList() {
|
||||
|
||||
@@ -592,6 +593,61 @@ exports.newGithubServer = function newGithubServer() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function closePrsToMaster() {
|
||||
|
||||
const per_page = 100 // Max
|
||||
let page = 0
|
||||
let lastPage = false
|
||||
|
||||
while (lastPage === false) {
|
||||
try {
|
||||
page++
|
||||
|
||||
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
|
||||
|
||||
let listResponse = await octokit.rest.pulls.list({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
state: 'open',
|
||||
head: 'develop',
|
||||
base: 'develop',
|
||||
sort: undefined,
|
||||
direction: undefined,
|
||||
per_page: per_page,
|
||||
page: page
|
||||
});
|
||||
|
||||
if (listResponse.data.length < 100) {
|
||||
lastPage = true
|
||||
}
|
||||
console.log('[INFO] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList -> Receiving Page = ' + page)
|
||||
for (let i = 0; i < listResponse.data.length; i++) {
|
||||
let pullRequest = listResponse.data[i]
|
||||
console.log('[INFO] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList -> Pull Request "' + pullRequest.title + '" found and added to the list to validate. ')
|
||||
githubPrListArray.push(pullRequest)
|
||||
}
|
||||
console.log('[INFO] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList -> Received = ' + listResponse.data.length)
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
||||
if (err.stack.indexOf('last page') >= 0) {
|
||||
return
|
||||
} else {
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->Method call produced an error.')
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->err.stack = ' + err.stack)
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->repository = ' + repository)
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->username = ' + username)
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->token starts with = ' + token.substring(0, 10) + '...')
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> getPrList ->token ends with = ' + '...' + token.substring(token.length - 10))
|
||||
error = err
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Github Server -> mergeGithubPullRequests -> doGithub -> err.stack = ' + err.stack)
|
||||
}
|
||||
|
||||
@@ -223,13 +223,13 @@ exports.newEvents = function newEvents() {
|
||||
|
||||
function addPost(post) {
|
||||
let postResponse = {
|
||||
emitterUserProfileId: post.emitterUserProfileId,
|
||||
targetUserProfileId: post.targetUserProfileId,
|
||||
emitterPostHash: post.emitterPostHash,
|
||||
targetPostHash: post.targetPostHash,
|
||||
postType: post.postType,
|
||||
userProfile: post.userProfile.userProfieId,
|
||||
timestamp: post.timestamp,
|
||||
repliesCount: post.replies.length,
|
||||
targetPostHash: post.targetPost.emitterPostHash,
|
||||
reactionsCount: []
|
||||
}
|
||||
|
||||
|
||||
@@ -109,13 +109,13 @@ exports.newPostReplies = function newPostReplies() {
|
||||
|
||||
function addToResponse(post) {
|
||||
let postResponse = {
|
||||
emitterUserProfileId: post.emitterUserProfileId,
|
||||
targetUserProfileId: post.targetUserProfileId,
|
||||
emitterPostHash: post.emitterPostHash,
|
||||
targetPostHash: post.targetPostHash,
|
||||
postType: post.postType,
|
||||
userProfile: post.userProfile.userProfieId,
|
||||
timestamp: post.timestamp,
|
||||
repliesCount: post.replies.length,
|
||||
targetPostHash: post.targetPost.emitterPostHash,
|
||||
reactionsCount: []
|
||||
}
|
||||
|
||||
|
||||
@@ -113,13 +113,13 @@ exports.newProfilePosts = function newProfilePosts() {
|
||||
|
||||
function addToResponse(post) {
|
||||
let postResponse = {
|
||||
emitterUserProfileId: post.emitterUserProfileId,
|
||||
targetUserProfileId: post.targetUserProfileId,
|
||||
emitterPostHash: post.emitterPostHash,
|
||||
targetPostHash: post.targetPostHash,
|
||||
postType: post.postType,
|
||||
userProfile: post.userProfile.userProfieId,
|
||||
timestamp: post.timestamp,
|
||||
repliesCount: post.replies.length,
|
||||
targetPostHash: post.targetPost.emitterPostHash,
|
||||
reactionsCount: []
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -8,9 +8,8 @@ exports.newPost = function newPost() {
|
||||
postType: undefined,
|
||||
timestamp: undefined,
|
||||
replies: undefined,
|
||||
targetPost: undefined,
|
||||
reactionsCount: undefined,
|
||||
reactionTypesCount: undefined,
|
||||
reactionTypesCount: undefined,
|
||||
addReaction: addReaction,
|
||||
removeReactions: removeReaction,
|
||||
initialize: initialize,
|
||||
@@ -59,7 +58,6 @@ exports.newPost = function newPost() {
|
||||
thisObject.postType = undefined
|
||||
thisObject.timestamp = undefined
|
||||
thisObject.replies = undefined
|
||||
thisObject.targetPost = undefined
|
||||
}
|
||||
|
||||
function initialize(
|
||||
@@ -82,6 +80,8 @@ exports.newPost = function newPost() {
|
||||
/*
|
||||
Let's find the Target Post
|
||||
*/
|
||||
let targetPost
|
||||
|
||||
if (
|
||||
event.eventType === POST_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === POST_TYPES.REPOST_MULTI_MEDIA ||
|
||||
@@ -90,9 +90,9 @@ exports.newPost = function newPost() {
|
||||
event.eventType === POST_TYPES.RE_POST_TRADE ||
|
||||
event.eventType === POST_TYPES.QUOTE_REPOST_TRADE
|
||||
) {
|
||||
thisObject.targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash)
|
||||
targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash)
|
||||
|
||||
if (thisObject.targetPost === undefined) {
|
||||
if (targetPost === undefined) {
|
||||
throw ('Target Post Not Found.')
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ exports.newPost = function newPost() {
|
||||
event.eventType === POST_TYPES.REPLY_TO_MULTI_MEDIA_POST ||
|
||||
event.eventType === POST_TYPES.REPLY_TO_TRADE_POST
|
||||
) {
|
||||
thisObject.targetPost.replies.push(thisObject)
|
||||
targetPost.replies.push(thisObject)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user