Governance Github Program Finished

This commit is contained in:
Luis Fernando Molina committed 2021-07-28 10:40:44 +02:00
1 parent ab65be7acb
commit 576c963b24
8 files changed
+171 -28

No files matched your search

+2 -1
View File
@@ -885,7 +885,8 @@
#governance-tab10:checked ~ .governance-search-result-content #content10,
#governance-tab11:checked ~ .governance-search-result-content #content11,
#governance-tab12:checked ~ .governance-search-result-content #content12,
#governance-tab13:checked ~ .governance-search-result-content #content13 {
#governance-tab13:checked ~ .governance-search-result-content #content13,
#governance-tab14:checked ~ .governance-search-result-content #content14 {
display: block;
}
@@ -120,14 +120,14 @@ function newGovernanceFunctionLibraryGithubProgram() {
return
}
let githubUsername = profileSignature.message
node.payload.githubProgram.hasStar = UI.projects.governance.spaces.userProfileSpace.githubStars.get(githubUsername)
node.payload.githubProgram.hasWatch = UI.projects.governance.spaces.userProfileSpace.githubWatchers.get(githubUsername)
node.payload.githubProgram.hasFork = UI.projects.governance.spaces.userProfileSpace.githubForks.get(githubUsername)
node.payload.githubProgram.starsCount = UI.projects.governance.spaces.userProfileSpace.githubStars.get(githubUsername)
node.payload.githubProgram.watchersCount = UI.projects.governance.spaces.userProfileSpace.githubWatchers.get(githubUsername)
node.payload.githubProgram.forksCount = UI.projects.governance.spaces.userProfileSpace.githubForks.get(githubUsername)
node.payload.githubProgram.engagement = 0
if (node.payload.githubProgram.hasStar === true) { node.payload.githubProgram.engagement++ }
if (node.payload.githubProgram.hasWatch === true) { node.payload.githubProgram.engagement++ }
if (node.payload.githubProgram.hasFork === true) { node.payload.githubProgram.engagement++ }
if (node.payload.githubProgram.starsCount > 0) { node.payload.githubProgram.engagement = node.payload.githubProgram.engagement + node.payload.githubProgram.starsCount }
if (node.payload.githubProgram.watchersCount > 0) { node.payload.githubProgram.engagement = node.payload.githubProgram.engagement + node.payload.githubProgram.watchersCount }
if (node.payload.githubProgram.forksCount > 0) { node.payload.githubProgram.engagement = node.payload.githubProgram.engagement + node.payload.githubProgram.forksCount }
if (
node.payload.githubProgram.engagement > 0) {
@@ -171,7 +171,7 @@ function newGovernanceFunctionLibraryGithubProgram() {
return
}
const MAX_ENGAGEMENT = 3
programNode.payload.githubProgram.awarded.tokens = programNode.payload.githubProgram.ownPower / totalPowerRewardRatio * programNode.payload.githubProgram.engagement / MAX_ENGAGEMENT
programNode.payload.githubProgram.awarded.tokens = programNode.payload.githubProgram.ownPower / totalPowerRewardRatio * programNode.payload.githubProgram.engagement / MAX_ENGAGEMENT
drawProgram(programNode)
}
@@ -199,13 +199,13 @@ function newGovernanceFunctionLibraryGithubProgram() {
node.tokensAwarded.payload.uiObject.statusAtAngle = false
let extraText = ''
if (node.payload.githubProgram.hasStar === true) {
if (node.payload.githubProgram.starsCount > 0) {
extraText = extraText + ' + 1 Star'
}
if (node.payload.githubProgram.hasWatch === true) {
if (node.payload.githubProgram.watchersCount > 0) {
extraText = extraText + ' + 1 Watch'
}
if (node.payload.githubProgram.hasFork === true) {
if (node.payload.githubProgram.forksCount > 0) {
extraText = extraText + ' + 1 Fork'
}
+1 -1
View File
@@ -1,6 +1,6 @@
function newGovernanceGlobalsReports() {
let thisObject = {
REPORTS_SPACE_WIDTH: 1150
REPORTS_SPACE_WIDTH: 1250
}
return thisObject
}
@@ -0,0 +1,139 @@
function newGovernanceReportsGithub() {
let thisObject = {
addHTML: addHTML,
initialize: initialize,
finalize: finalize
}
return thisObject
function initialize() {
}
function finalize() {
}
function addHTML(tabIndex, filters) {
/*
Parameters
*/
let table = 'github'
let programName = 'Github Program'
let programPropertyName = 'githubProgram'
/*
Setup Filters
*/
let filtersObject
if (filters !== undefined) {
try {
filtersObject = JSON.parse(filters)
} catch (err) { }
}
/*
Other Variables
*/
let tableRecords = []
let tableRecordDefinition = {
"properties": [
{
"name": "name",
"label": "User Profile",
"type": "string",
"order": "ascending",
"textAlign": "left"
},
{
"name": "githubPower",
"label": "Github Power",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
},
{
"name": "stars",
"label": "Stars",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "integer"
},
{
"name": "watching",
"label": "Watching",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "integer"
},
{
"name": "forks",
"label": "Forks",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "integer"
},
{
"name": "tokensAwarded",
"label": "Awarded",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
}
]
}
/*
Here we get from the workspace all User Profiles.
*/
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
/*
Transform the result array into table records.
*/
for (let j = 0; j < userProfiles.length; j++) {
let userProfile = userProfiles[j]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programName)
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
let tableRecord = {
"name": userProfile.name,
"githubPower": program.payload[programPropertyName].ownPower | 0,
"stars": program.payload[programPropertyName].starsCount | 0,
"watching": program.payload[programPropertyName].watchersCount | 0,
"forks": program.payload[programPropertyName].forksCount | 0,
"tokensAwarded": program.payload[programPropertyName].awarded.tokens | 0
}
if (UI.projects.governance.utilities.filters.applyFilters(filters, filtersObject, tableRecord) === true) {
tableRecords.push(tableRecord)
}
}
/*
Get the sorting order for this table.
*/
let sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
/*
Set the default sorting order for this table.
*/
if (sortingOrder === undefined) {
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
property: 'tokensAwarded',
order: 'descending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
return UI.projects.governance.utilities.tables.addHTML(
table,
tableRecords,
tableRecordDefinition,
sortingOrder,
tabIndex
)
}
}
@@ -30,7 +30,7 @@ function newGovernanceReportsReportsPage() {
buildHTML()
function buildHTML() {
const tabs = ['Profiles', 'Referrals', 'Supporters', 'Mentors', 'Claims', 'Votes', 'Staking', 'Delegation', 'Pools', 'Assets', 'Features', 'Positions', 'Mining']
const tabs = ['Profiles', 'Referrals', 'Supporters', 'Mentors', 'Claims', 'Votes', 'Staking', 'Delegation', 'Github', 'Pools', 'Assets', 'Features', 'Positions', 'Mining']
let HTML = ''
HTML = HTML + '<section id="governance-report-page-div" class="governance-search-page-container">'
HTML = HTML + UI.projects.governance.spaces.reportsSpace.filtersHeader.addFilterHeader()
@@ -104,6 +104,12 @@ function newGovernanceReportsReportsPage() {
resultCounter = response.resultCounter
break
}
case 'Github': {
let response = UI.projects.governance.spaces.reportsSpace.github.addHTML(8, filters)
HTML = HTML + response.HTML
resultCounter = response.resultCounter
break
}
case 'Pools': {
let response = UI.projects.governance.spaces.reportsSpace.pools.addHTML(9, filters)
HTML = HTML + response.HTML
@@ -15,6 +15,7 @@ function newGobernanceReportsSpace() {
votes: undefined,
staking: undefined,
delegations: undefined,
github: undefined,
pools: undefined,
assets: undefined,
features: undefined,
@@ -85,6 +86,9 @@ function newGobernanceReportsSpace() {
thisObject.delegation.finalize()
thisObject.delegation = undefined
thisObject.github.finalize()
thisObject.github = undefined
thisObject.pools.finalize()
thisObject.pools = undefined
@@ -131,6 +135,7 @@ function newGobernanceReportsSpace() {
thisObject.votes = newGovernanceReportsVotes()
thisObject.staking = newGovernanceReportsStaking()
thisObject.delegation = newGovernanceReportsDelegation()
thisObject.github = newGovernanceReportsGithub()
thisObject.pools = newGovernanceReportsPools()
thisObject.assets = newGovernanceReportsAssets()
thisObject.features = newGovernanceReportsFeatures()
@@ -147,6 +152,7 @@ function newGobernanceReportsSpace() {
thisObject.votes.initialize()
thisObject.staking.initialize()
thisObject.delegation.initialize()
thisObject.github.initialize()
thisObject.pools.initialize()
thisObject.assets.initialize()
thisObject.features.initialize()
@@ -45,16 +45,8 @@ function newGovernanceReportsStaking() {
"textAlign": "left"
},
{
"name": "ownPower",
"label": "Own Power",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
},
{
"name": "incoming",
"label": "Incoming",
"name": "stakingPower",
"label": "Staking Power",
"type": "number",
"order": "descending",
"textAlign": "center",
@@ -87,8 +79,7 @@ function newGovernanceReportsStaking() {
let tableRecord = {
"name": userProfile.name,
"ownPower": program.payload[programPropertyName].ownPower | 0,
"incoming": program.payload[programPropertyName].incomingPower | 0,
"stakingPower": program.payload[programPropertyName].ownPower | 0,
"tokensAwarded": program.payload[programPropertyName].awarded.tokens | 0
}
@@ -103,7 +103,7 @@ function newGovernanceUserProfileSpace() {
for (let i = 0; i < githubStarsArray.length; i++) {
let githubUsername = githubStarsArray[i]
thisObject.githubStars.set(githubUsername, true)
thisObject.githubStars.set(githubUsername, 1)
}
requestWatchers()
@@ -116,7 +116,7 @@ function newGovernanceUserProfileSpace() {
for (let i = 0; i < githubWatchersArray.length; i++) {
let githubUsername = githubWatchersArray[i]
thisObject.githubWatchers.set(githubUsername, true)
thisObject.githubWatchers.set(githubUsername, 1)
}
requestForks()
@@ -129,7 +129,7 @@ function newGovernanceUserProfileSpace() {
for (let i = 0; i < githubForksArray.length; i++) {
let githubUsername = githubForksArray[i]
thisObject.githubForks.set(githubUsername, true)
thisObject.githubForks.set(githubUsername, 1)
}
}
}