Just to remind that the Activity required to reach the Legendary rank is a random value that depends on the UserId of the profile, and a secretSeed which, for obvious reasons, we do not have:
<…> Currently this randomness is done with a single SQL query, which is very convenient.
update smf_members
set ID_POST_GROUP=21
where ID_POST_GROUP=8
and activity>=775 and activity>=775+conv(substr(sha1(concatenate(ID_MEMBER,secretSeed)), 1, 2), 16, 10)
<…>
Note: I had to replace "concat" with "concatenate" in the above quote to be able to publish the post.