Hi Morbus,
I'm going to describe a particular/complex task to meet a particular need for my site, and I would really love to hear your own opinion.
Premise: I'm doing a migration from an old (non drupal) website to a new Drupal 7 version of the same (I'm using migrate module for this). In this old website there's something similar to a "userpoints system": users gain points for their actions in the site (write a comment, vote a content and so on).
My new Drupal site now uses achievements for this scope, and there isn't any correspondence between the old "userpoints" and the new "achievements" system. I don't want to install the userpoint module and do an integration with this one in the new site, but in the same time I don't want to loose all points old users have actually gained... I have to keep track of that... So, here's what I thought to resolve the issue:
potential solution: step by step:
- add a new column in the leaderboard, near to the existing "Points" one, called "Points from old website", as a historical memory.
- this new column shows the old users points
- the existing "Points" column should now show the achievements system point PLUS the next cell old points amount (so the Points column values are equals to achievements points + old points)
- To do what described until now I think I simply have to implement hook_achievements_leaderboard_alter() to add the new column: isn't?
- The key point is: where to store (and then retrieve) this old users points data? Well, I think I can implement an hook_schema_alter (or hook_update_N ... I've never done it, so I have to learn) to add a new column to achievement_total table provided by achievements module, and then fill this column during my data migration...
I don't know... What do you think about that?
Thank you very much for your support
MXT
Comments
Comment #1
mxtHi Morbus, I would really like to hear your opinion on this...
Thank you very much
Comment #2
mxtHere I am, after some months, with the same issue.
Update of the situation:
I'm now able to add a new column in the global leaderboard, in this way:
Ok, this works, but now I have to insert real values instead of 'TEST ' . $key, so I think to proceed in this way:
This is the best solution I can find at the moment, I think performance issues are negligible because leaderboard shows paginated results, and so the query is executed for a max of 10 - 20 times (it depends on the number of rows the leaderboard shows, based on settings in admin page).
Can you guys give me any advices on this? Is there a better way to proceed?
I've also discarded the idea to add the new column in the existing 'achievements_totals' table and then use hook_query_alter() to alter the 'achievement_totals' query to add the new column in results: I have no idea on how to inject the query results in the render array built in achievements_leaderboard_totals function provided by achievements module (there is no way to override this function and I don't want hack the original code)
Thank you very much for any help
MXT