create account

[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize) by tobias-g

View this thread on: hive.blogpeakd.comecency.com
· @tobias-g · (edited)
$52.99
[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)
#### Repository

https://github.com/tobias-g1/contest-hero

Contest Hero is a new app built on top of the Steem Blockchain that allows you to easily create, manage, find and enter great contests on the Steem blockchain. The following is an update surrounding the development of Contest Hero. If you want to take a look at the site, you can use the link below:

https://contesthero.io

You can also find out more about the Contest Hero in the following post:

https://steemit.com/@contest-hero/introducing-contest-hero-create-contests-on-the-steem

Here's an overview of the changes in this update, although there isn't as many as usual it's been over a week since my last update due to some other work I needed to complete so this release is long overdue.

### New Features
</br>

1. Ability to assign prize type and prize value upon contest creation
2. Ability to edit prize type and prize value upon contest edit
3. Ability to filter feed by prize type
4. Ability to resteem post

### Improvements
</br>

1. Improved code block styling (small, but mentioned by a member on Discord)
2. Created consistency between post and comment components
3. Created shared mixin between contest edit and creation pages
4. Added time since post indicator

### Bug Fixes
</br>

1. Resolved issue with footer appended to contest and contest entries becoming skewed
2. Resolved issue with contest/entry/comment value disappearing following post-payout
3. Resolved issue with contest getting locked before deadline surpassing.

The changes mentioned above relate to the following pull requests:

https://github.com/tobias-g1/contest-hero/pull/118

and 

https://github.com/tobias-g1/contest-hero/pull/120 (when reviewing my code for this post, I relealised I made a minor error)

One of the main features within this release was the ability to set both a prize type and prize value within the contest creation page. The following image shows how this looks on the contest creation page:

![screely-1541443984946.png](https://ipfs.busy.org/ipfs/QmWaEKjHQ1LaPu3HHLBjw9RV7LJghLc6Rqi84t6yyTtD66)

Currently, a Contest Hero user has the ability to select from the following prize types:

1. STEEM
2. SBD
3. Steem Monsters
4. Other 
5. None

The main reason that I wanted to sort these into categories was to allow for filtering on the Contest page, now a user has the ability to select from the prize dropdown to filter their feed relevant to their selection. This can be seen in the image below:

![screely-1541443544915.png](https://ipfs.busy.org/ipfs/QmfQndE1WFpT3eyfDZ4KhuVwB6rLH9VaroEoPErVFnaUWZ)

The prize that is set by a user is also shown on the view contest page, currently, this is only a simple indicator to show whether the prize value and category. This can be seen in the image below:

![screely-1541444057860.png](https://ipfs.busy.org/ipfs/QmZaNUnNmmTBp2DrdWaphrttZJbUvmr6iFHJeGiZwxkv3V)

From the above you can see there was a number of different client-side changes made during this release, this was combined with a few server-side adjustments that I need to make. In order to allow for a contest prize to be set, I needed to make an adjustment to the contest model to take into account the prize object. 

```
prize:  {

type:  {

type:  String,

required:  true

},

value:  {

type:  String,

required:  true

}
```
Following this addition, I need to make an adjustment to the `create_contests` call in the controller to add the prize into the request body. 

```
prize:  {

type:  req.body.prize.type,

value:  req.body.prize.value

}
```

and then in order to validate the request, I also need to add some additional validation to `contests.valdation.js`

```
prize:  {

type:  Joi.string().required(),

value:  Joi.string().required()

}
```

After I created the ability set prizes I needed to make an adjustment to both the `get_contests` and `get_contests_by_category` calls (*I will be consolidating these calls in the next release as the planned features have quite a few API changes.*), to provide the ability for the client to filter based on a user's selection within the feed, the following shows how currently form query for `get_contest_by_category` based on the parameters passed into the API:

```

let query =  (req.params.prize === 'any') ? { "category": req.params.category } : {"category": req.params.category, "prize.type": req.params.prize}

Contest.find(query,  function  (error,  contests)  {

if (error) {

console.error(error);

}

res.send({

contests:  contests

})

}).sort(sortmethod)

}

```

Based on a user selection with the UI, the call will be sent with the prize and category parameter in the response, following this the response will be filtered to their selection server side. Although the current method for building the query doesn’t scale well, I plan to rewrite both this call in the next release as there are numerous feed options that I want to implement. 

The commits that related to the prize creation are here:

**Add prize option contest form**

https://github.com/tobias-g1/contest-hero/commit/8eaca6fcda407ca64846731697455852a163a5f0

**Ability to filter feed by prize**

https://github.com/tobias-g1/contest-hero/commit/c4f616b4ca5b2e5f1b4d37bbb390833d6fb7eebe

**Show prize on contest page**

https://github.com/tobias-g1/contest-hero/commit/a822510ec4e4f909043ac92ff58dbfb7874c12c5

**Missed elements for prize entries, Ability to edit contest prizes, Contest Mixin**

https://github.com/tobias-g1/contest-hero/commit/8545a6e78c77285a619ee39373acb8f08a45e970

Next, I added the ability for a user to reblog from Contest Hero. In order to do this I added a new icon to post-options component, when pressed this icon will trigger the dialog shown below:

![screely-1541443615131.png](https://ipfs.busy.org/ipfs/QmfK6kFi1TxhgcFPsn7MKujvqxuQkZRzLrX8xumkHJwMwU)

A user then has the ability to select whether or not they would like to confirm their reblog of a particular post. Currently there is no indicator as to whether or not a contest or entry has been reblogged as their is no easy method to check this (at least in JS or I know of) so currently this is a known issue in the user experience. Although this particular feature makes us of existing functionality within `vue-steemconnect` this particular feature is important for contest creators who want to their contests to promote their contest using the Contest Hero front end. 

This can be seen in this commit:

https://github.com/tobias-g1/contest-hero/commit/3991b29a373cee00702ee90c19532b5c5c343dda

Within this release I also realised that I was incorrect in my implementation surrounding how rewards were displayed on Contest Hero, I found that the value associated to a post would disappear following a post's payout. This was because I was only taking into account `pending_post_payout`, in order to resolve this issue I created the following computed property:

```
payout:  function  ()  {

let  postCreationDate  =  moment(this.post.created)._d

let  currentDate  =  moment()._d

let  timesince  =  moment(currentDate).diff(postCreationDate,  'minutes')

if (timesince  >  10080) {

return  parseFloat(this.post.curator_payout_value) +  parseFloat(this.post.total_payout_value)

}  else  {

return  this.post.pending_payout_value

}

}
```

Within this property I used moment.js to get the current date and format the creation time of the post, following that I would then calculate the difference and then if the time since was greater than 10080 minutes (7 days) I would return the sum of `curator_payout_value` and `this.post.total_payout_value`.  The reason I mention this, is because it might be useful for somebody else who is thinking about building their own front end. 

Aside from the mentioned above, I also took the chance to improve some of the duplication with the codebase, the area I tackled were related to the creation and editing contests. In order to do this I removed a lot of duplicated code in both `create-contest.vue` and `edit-contest.vue` and instead introduced `mixins/contest.js`. Within the newly created mixin I now am able to share code need for form validation, tag creation, image capture and prizes. Although there is still the issue to tackle surrounding the two identical form UI elements, this is a good start surrounding maintenance of those pages. 

This can be seen in this commit:

https://github.com/tobias-g1/contest-hero/commit/8545a6e78c77285a619ee39373acb8f08a45e970

(Apologies, it's a bit mixed into the overall editing of a contest prize)

I also found that in a previous release I had adjusted the contest markdown parser without adjusting the comment or entry pages, this was mainly due the code being different being throughout all of the different pages. I therefore created a single component that can be used to reference when using the markdown panel. This can be seen in this commit:

https://github.com/tobias-g1/contest-hero/commit/505c783289724429161019bd9c7f2158eab28331

### GitHub Account

A link to my GitHub can be found here:

https://github.com/tobias-g1/
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authortobias-g
permlinkcontest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize
categoryutopian-io
json_metadata{"tags":["utopian-io","development","steemtank","contest-hero"],"app":"steemit/0.1","image":["https://ipfs.busy.org/ipfs/QmWaEKjHQ1LaPu3HHLBjw9RV7LJghLc6Rqi84t6yyTtD66","https://ipfs.busy.org/ipfs/QmfQndE1WFpT3eyfDZ4KhuVwB6rLH9VaroEoPErVFnaUWZ","https://ipfs.busy.org/ipfs/QmZaNUnNmmTBp2DrdWaphrttZJbUvmr6iFHJeGiZwxkv3V","https://ipfs.busy.org/ipfs/QmfK6kFi1TxhgcFPsn7MKujvqxuQkZRzLrX8xumkHJwMwU"],"links":["https://github.com/tobias-g1/contest-hero","https://contesthero.io","https://steemit.com/@contest-hero/introducing-contest-hero-create-contests-on-the-steem","https://github.com/tobias-g1/contest-hero/pull/118","https://github.com/tobias-g1/contest-hero/pull/120","https://github.com/tobias-g1/contest-hero/commit/8eaca6fcda407ca64846731697455852a163a5f0","https://github.com/tobias-g1/contest-hero/commit/c4f616b4ca5b2e5f1b4d37bbb390833d6fb7eebe","https://github.com/tobias-g1/contest-hero/commit/a822510ec4e4f909043ac92ff58dbfb7874c12c5","https://github.com/tobias-g1/contest-hero/commit/8545a6e78c77285a619ee39373acb8f08a45e970","https://github.com/tobias-g1/contest-hero/commit/3991b29a373cee00702ee90c19532b5c5c343dda","https://github.com/tobias-g1/contest-hero/commit/505c783289724429161019bd9c7f2158eab28331","https://github.com/tobias-g1/"],"format":"markdown"}
created2018-11-05 22:25:57
last_update2019-02-02 16:40:00
depth0
children6
last_payout2018-11-12 22:25:57
cashout_time1969-12-31 23:59:59
total_payout_value39.802 HBD
curator_payout_value13.191 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9,046
author_reputation101,057,581,296,921
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries
0.
accountutopian.pay
weight500
max_accepted_payout100,000.000 HBD
percent_hbd10,000
post_id74,749,828
net_rshares50,766,744,135,900
author_curate_reward""
vote details (60)
@amosbastian ·
Very cool! I was planning on making a contest yesterday, and was confused why there wasn't an option to select the prize and amount - great to see you added that.
👍  
properties (23)
authoramosbastian
permlinkre-tobias-g-contest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize-20181106t150057198z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-06 15:00:57
last_update2018-11-06 15:00:57
depth1
children0
last_payout2018-11-13 15:00:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length162
author_reputation174,473,586,900,705
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,793,043
net_rshares4,849,618,766
author_curate_reward""
vote details (1)
@codingdefined ·
$9.46
Thank you for your contribution. It's good to see one new dApp is building and also good to see that you are constantly improving it. It's a very high-quality post, just that the code section in the post looks little unorganized (with a lot of spaces and not indent), though its just minor thing. You are doing great, kudos to that.

----

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/1322212).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
👍  , , , , , , , , , ,
properties (23)
authorcodingdefined
permlinkre-tobias-g-contest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize-20181106t123601624z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/1322212","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-11-06 12:36:03
last_update2018-11-06 12:36:03
depth1
children1
last_payout2018-11-13 12:36:03
cashout_time1969-12-31 23:59:59
total_payout_value7.154 HBD
curator_payout_value2.302 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length829
author_reputation533,474,527,074,378
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,784,763
net_rshares8,666,013,938,445
author_curate_reward""
vote details (11)
@utopian-io ·
Thank you for your review, @codingdefined! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-tobias-g-contest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize-20181106t123601624z-20181108t190310z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-08 19:03:12
last_update2018-11-08 19:03:12
depth2
children0
last_payout2018-11-15 19:03:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length65
author_reputation152,955,367,999,756
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,932,873
net_rshares0
@steem-plus ·
SteemPlus upvote
Hi, @tobias-g!

You just got a **3.86%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
authorsteem-plus
permlinkcontest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize---vote-steemplus
categoryutopian-io
json_metadata{}
created2018-11-06 07:55:06
last_update2018-11-06 07:55:06
depth1
children0
last_payout2018-11-13 07:55:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length435
author_reputation247,952,188,232,400
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,772,368
net_rshares0
@steem-ua ·
#### Hi @tobias-g!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-contest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize-20181106t133242z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-06 13:32:45
last_update2018-11-06 13:32:45
depth1
children0
last_payout2018-11-13 13:32:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length287
author_reputation23,214,230,978,060
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,787,953
net_rshares0
@utopian-io ·
Hey, @tobias-g!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-contest-hero-development-update-add-prize-to-contest-edit-prize-reblog-filter-feed-by-prize-20181106t195146z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-06 19:51:48
last_update2018-11-06 19:51:48
depth1
children0
last_payout2018-11-13 19:51:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length590
author_reputation152,955,367,999,756
root_title"[Contest Hero] Contest Hero Development Update (Add prize to contest, edit prize, reblog, filter feed by prize)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,808,030
net_rshares0