Converting XenForo post ratings to IPS reactions

Discussion in 'Invision Community' started by Optic, Jul 29, 2017.

  1. Optic

    Optic Enthusiast

    183
    55
    +117
    Has anyone been successful in doing this?

    I did a test convert and the inbuilt converter only recognises native XF likes.

    I know you can revert all the XF post ratings to normal XF vanilla likes, but would be great to map them to IPS reactions as the add-on post ratings has been used extensively already..
     
  2. Matt C.

    Matt C. Gaming Fanatic

    91
    35
    +94
    I would ask on the IPS forums, you'd probably have more success there. Worst case scenario, you will have to pay someone to convert them.
     
  3. Tracy Perry

    Tracy Perry Opinionated asshat

    5,202
    552
    +3,599
    It will take a custom converter to do that I'm pretty sure. The native function only maps the XF ones and most conversions do not account for add-ons in their conversion routines.
    It honestly shouldn't be to hard to do.
     
  4. Optic

    Optic Enthusiast

    183
    55
    +117
    Thanks for the thoughts, given this is the only issue I wonder if it could be achieved via a bulk edit in the database..

    I'll post my results in due course. :)
     
  5. Mouth

    Mouth Enthusiast

    193
    93
    +108
    Any progress?
     
  6. Optic

    Optic Enthusiast

    183
    55
    +117
    Hi MouthMouth

    I actually forgot about this as I was reporting a bug with the activity stream (on profiles) in IP.Gallery where uploading multiple images in one go would result in a row for each individual row, flooding the profile... Thankfully they confirmed an upcoming fix for the next third point version coming soon (it's in Beta)

    So going back to this I took a look at the database.


    IPS side

    The reactions are being stored in the core_reputation_index table.

    It has these columns:
    id member_id app type type_id rep_date rep_rating member_received rep_class item_id class_type_id_hash reaction

    It looks quite straightforward. The app and type varies of course depending on which module the Reaction is used in, e.g. whether it's in a forum post, a status update, a gallery album/image, a club, even a 3rd party add-on application. And of course the reaction is the ID of the reaction.

    Example row for a forum post:
    11409 2007 forums pid 42142 1502609757 1 1333 IPS\forums\Topic\Post 3581 1ba98192c52ed2a081a0bc1b0a5c41d9 1

    Example row for a status update:
    11405 201 core status_id 5403 1502449772 1 1214 IPS\core\Statuses\Status 0 53865270cd955ae71b86b7ea6308af9d 6


    The issue is the class_type_id_hash, I don't know how to generate that. Presumably if you're doing it properly you'd be using the proper model as per the developer documentation:
    https://invisioncommunity.com/developers/docs/invision-community-42/reactions-r116/


    XenForo side

    Native XF likes are stored in the xf_liked_content table

    It has these columns:
    like_id content_type content_id like_user_id like_date content_user_id

    Example row for a forum post:
    25697 post 44001 1831 1503611646 2453

    Example row for a status update:
    25696 profile_post_comment 11210 489 1503611229 764


    Comparing both XF and IPS likes in my test import, the XF like_id field matches with IPS's id field


    XenForo - Post Ratings add-on side
    Post Ratings add-on ratings are stored in the dark_postrating table

    It has these columns:
    id post_id user_id rated_user_id rating date

    Example post rating:
    8721 44116 1917 2038 2 1503345110

    The post_id here of course matches the XF content_id

    So should be able to do a bulk import in the database by matching the field IDs, reaction IDs, and so on, but just not sure on that class_type_id_hash... that's the only roadblock ..
     
  7. Daniel

    Daniel Guest

    +12
    It's quite easy to find the value for class_type_id_hash by checking the code :)

    Code:
    'class_type_id_hash'    => md5( static::reactionClass() . ':' . $this->$idColumn ),
    You could also take a look at the converter app, specially the Library/Core::convertReputation method to see how it's calculated for conversions

    Hope this helps:)
     
    • Informative! Informative! x 2
    • List
  8. Optic

    Optic Enthusiast

    183
    55
    +117
    Ah so at quick glance it's an MD5 hash of the ID field for each row?

    I tried to MD5 hash value: 11409 to try and match my example above:
    1ba98192c52ed2a081a0bc1b0a5c41d9

    I got:
    1b554caad50131478083eb6e4f7845d6

    So it seems I'm hashing the wrong value or there is salt involved to make it different.

    Will try looking at the Converter code, thanks. :)
     
  9. Daniel

    Daniel Guest

    +12
    No its the md5 hash value of classname : id
     
  10. Optic

    Optic Enthusiast

    183
    55
    +117
    Thanks DanielDaniel!

    I can generate the correct MD5 hash now for that field. :)

    Now just need to see if there any cache rebuilds are required when inserting new reaction records directly into the IPS core_reputation_index table..
     
  11. Ryan Ashbrook

    Ryan Ashbrook IPS Developer

    3,712
    1,127
    +690
    You'll want to rebuild members reputation counts (this can be done from any users profile in the Admin CP), and then rebuild the Leaderboard, which can be done in the ACP > Members > Reputation & Reactions > Leaderboard
     
    • Informative! Informative! x 3
    • List
  12. Alfa1

    Alfa1 Administrator

    3,750
    1,702
    +2,625
    How far are you with the migration? I see your site is off line since the 13th.
     
    • Also Wondering! Also Wondering! x 1
    • List
  13. Optic

    Optic Enthusiast

    183
    55
    +117
    Hi Alfa1Alfa1 - I am really close, just doing some manual copy and pasting from some old WordPress blog posts to IP.Blog, re-uploading galleries to IP.Gallery and need to manually feature topics again (CTA Featured Threads to native IPS Our Picks - Promotion)

    Yes indeed I was delayed, managed to get the XF Post Ratings migrated across to IPS Reactions in the end. The delay (combined w/ full-time work schedule) was because I forgot that after the conversion, the post ID numbers change. Not a problem for the URLs themselves as the IPS Converter app takes cares of redirects, but to generate the MD5 hashes for the IPS reactions I needed the IPS post IDs. Of course the XF post ratings table only had the XF post IDs so I had to cross-reference them from the IPS converter log table - dealt with that using good ol' VLOOKUP in Excel. Then imported the CSV and ran the rebuilds as noted above.

    On top of that, I bumped into a new issue today. IPS has a Image Proxy for storing off-site images on the server to maintain SSL (very similar to XenForo's one) however after enabling it and letting it rebuild all posts, this caused all inline images to turn into hyperlinks (even file upload attachments). Disabling the Image Proxy restores the images.. I've got a ticket open for this issue.
     
    • Informative! Informative! x 2
    • List
  14. synt4xAlarm

    synt4xAlarm Neophyte

    3
    1
    +0
    I have the same problem as OpticOptic but I didn't understand where can I find 'classname' and 'id' to hash the MD5. Maybe anyone can help me or has an idea where I could find these? Thanks!
     
  15. synt4xAlarm

    synt4xAlarm Neophyte

    3
    1
    +0
    Somebody maybe knows which values Daniel was meaning?
     
  16. Optic

    Optic Enthusiast

    183
    55
    +117
    synt4xAlarmsynt4xAlarm

    It has been a long time since I did the conversion, I generated it by converting the below:
    rep_class:type_id

    Both the above fields are in the core_reputation_index table

    It may have changed since then.
     
  17. synt4xAlarm

    synt4xAlarm Neophyte

    3
    1
    +0
    OpticOptic

    Thank you so much, it worked! :)
     
Verification:
Draft saved Draft deleted
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.