Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mila Pandurska 43 posts 190 karma points
    May 01, 2018 @ 09:03
    Mila Pandurska
    0

    Publishing Events

    Hi, I have a website where I store nodes and search them with lucene - by keyword and I return the results sorted by updateDate. I have custom search indexes and in addition I have some custom logic in Umbraco.Core.Services.ContentService.Published += _contentServiceEventHandlers.ContentService_Published;

    My website users can vote for this nodes. The problem is that when a user vote for node the updateDate updates and this node is shown before the others. Is there a way to prevent this. I don't want the updateDate to be changed when a user votes. I use very simple solution for voting - I just have a property in the node "Rating" and I use SaveAndPublish() to save the rating.

    I was thinking to create additional field lastUpdateDate and to make the sorting over this field but as I metioned I already have a lot of custom logic in Published event and I don't know who is making the Published event - users with voting or the site admins. If the site admins are publishing then the lastUpdateDate should be updated as well. Is there a way to know who is publishing?

    Please help

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 01, 2018 @ 09:23
    Dave Woestenborghs
    100

    Hi Mila,

    Personally I don't think storing user votes in content is good solution.

    Why ?

    Each time you update the vote in the content you will publish the item again. This will empty the Umbraco cache, examine indexes need to be rebuild etc... Causing a performance hit.

    It's better to store this kind of information in your own datasource, for example a database table.

    Here are some blogs explaing how you can use your own tables with umbraco.

    http://umbracodynamics.blogspot.nl/2016/08/umbraco-petapoco-to-store-blog-comments.html

    https://www.wiliam.com.au/wiliam-blog/using-petapoco-with-umbraco-is-pretty-sweet

    https://creativewebspecialist.co.uk/2013/07/16/umbraco-petapoco-to-store-blog-comments/

    Dave

  • Mila Pandurska 43 posts 190 karma points
    May 03, 2018 @ 04:30
    Mila Pandurska
    0

    Hi, Dave, Thank you for pointing out the potential problems. I implemented POCO classes successfully following the articles in your comment.

    Regards Mila

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies