Skip to content

Commit

Permalink
remove rating updates convergence
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Oct 10, 2023
1 parent 18e9ded commit 53f78de
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ pub fn add_criterion_for_objector(
input: AddCriterionForObjectorInput,
) -> ExternResult<ActionHash> {

call(
CallTargetCell::Local,
ZomeName::from(String::from("converge")),
FunctionName(String::from("remove_criterion_for_objector")),
None,
RemoveCriterionForObjectorInput{
base_objector: input.base_objector.clone(),
target_criterion_hash: input.target_criterion_hash.clone(),
}
)?;
if input.base_objector.clone().eq(&agent_info()?.agent_latest_pubkey) {
call(
CallTargetCell::Local,
ZomeName::from(String::from("converge")),
FunctionName(String::from("remove_criterion_for_objector")),
None,
RemoveCriterionForObjectorInput{
base_objector: input.base_objector.clone(),
target_criterion_hash: input.target_criterion_hash.clone(),
}
)?;
}

// remove previous support
let links = get_links(
Expand Down
5 changes: 5 additions & 0 deletions ui/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ h2 {
text-align: left;
} */

.dashboard-item {
cursor: pointer;
}

.dashboard-item > div {
white-space: pre-line;
margin: 6px;
Expand Down Expand Up @@ -147,6 +151,7 @@ body {

.list-item-mini {
height: 100px;
cursor: pointer;
}

.two-sides {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/converge/converge/Criteria/Criterion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ async function scrollToDiv() {
</div>
</div>
<div class="two-sides" bind:this={myDiv}>
<div style="display: flex; flex-direction: column">
<div style="display: flex; flex-direction: column; width: 100%;">
<!-- <div style="display: flex; flex-direction: row">
<span style="flex: 1"></span>
<mwc-icon-button style="margin-left: 8px" icon="delete" on:click={() => deleteCriterion()}></mwc-icon-button>
Expand All @@ -290,7 +290,7 @@ async function scrollToDiv() {
<!-- <span style="white-space: pre-line">{ criterion.objections }</span> -->
{#if support}
<div style="display: flex; flex-direction: row; font-size: .8em">
support: {support / supporters.length}
support: {Math.round(support / supporters.length * 100)}%
</div>
<!-- <div style="display: flex; flex-direction: row; font-size: .8em">
{JSON.stringify(support / supporters.length)} average support
Expand Down Expand Up @@ -407,7 +407,7 @@ async function scrollToDiv() {
</div>

<!-- OBJECT BUTTON -->
<div style="display: flex; flex-direction: column; font-size: .8em">
<div style="flex-direction: column; font-size: .8em; width: 100%; text-align: right;">
<button style="height: 80%;; width: 80px;
background-color: transparent;
border: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ onMount(async () => {
console.log(typeof(payload))
if (payload == 'activity received') {
console.log(signal)
setTimeout(() => {
// setTimeout(() => {
console.log("activity received")
outdated = true;
}, 2000);
// }, 2000);
// fetchDeliberation();
}
// console.log(payload)
Expand Down Expand Up @@ -331,7 +331,7 @@ async function leaveDeliberation() {
{#if activeTab == "criteria"}
<!--<FaSort/> -->
<p>What characteristics should a proposal have?</p>
<select bind:value={criteriaSort}>
<select bind:value={criteriaSort} style="cursor: pointer">
{#each sortByOptions as option}
<option value={option}> Sort by: {option}</option>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/converge/converge/Proposals/ProposalListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async function deleteProposal() {
</div>

<div class="overflow-content" style="display: flex; flex-direction: row; margin-bottom: 16px; font-size: 0.8em; position: relative;">
<span style="white-space: pre-line">score: { convergence / maxWeight * 100 }%</span>
<span style="white-space: pre-line">score: { Math.round(convergence / maxWeight * 100) }%</span>
</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/converge/converge/Proposals/RateCriteria.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $: if (allRatings) {
}
// if (Object.keys(allWeight).length > 0) {
convergence = calculateAverage(allWeight)
// console.log("convergence", convergence)
console.log("convergence", convergence)
// }
}
Expand Down
32 changes: 31 additions & 1 deletion ui/src/converge/converge/Proposals/RateCriterion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async function fetchSupport() {
sponsored = supporters.some(item => item["agent"] === client.myPubKey.join(","));
}
allSupport[criterionHash.join(',')] = averageSupport;
console.log("all support" + JSON.stringify(allSupport))
}
} catch (e) {
console.log(e)
Expand Down Expand Up @@ -206,6 +207,32 @@ async function fetchObjections() {
// error = e;
// }
// }
async function removeRatingAndFetch() {
await removeRating()
console.log("ASDFASDFASDF" + JSON.stringify(supporters))
console.log(client.myPubKey.join(","))
supporters = supporters.filter(item => item.agent !== client.myPubKey.join(","));
console.log("ASDFASDFASDF" + JSON.stringify(supporters))
let objectionCount;
if (objections) {
objectionCount = objections.length;
} else {
objectionCount = 0;
}
let adjustedSupport = Math.max(0, support - objectionCount)
// console.log(objections, support, objectionCount, adjustedSupport)
if (supporters.length > 0) {
averageSupport = adjustedSupport / supporters.length
} else {
averageSupport = 0;
}
if (supporters) {
sponsored = supporters.some(item => item["agent"] === client.myPubKey.join(","));
}
allSupport[criterionHash.join(',')] = averageSupport;
console.log(allSupport)
dispatch('proposal-rated')
}
async function removeRating() {
try {
Expand Down Expand Up @@ -369,7 +396,10 @@ async function addRating() {
MET</span>
</div>
<div style="text-align: center; flex-direction: row; font-size: 1em">
<button on:click={removeRating} style="white-space: pre-line;">Remove evaluation</button>
<button on:click={e => {
removeRatingAndFetch();
}}
style="white-space: pre-line;">Remove evaluation</button>
</div>
<!-- <div style="text-align: center; flex-direction: row; mfont-size: .8em"> -->
<!-- <button on:click={() => openEvaluation = false}>Cancel</button> -->
Expand Down

0 comments on commit 53f78de

Please sign in to comment.