3 attributes are fetched for writing the off-chain worker: User_ID, Track_ID, Stream_Duration. The following steps are applied to arrive at the result:
1) Sort by the all User_Id
2) Calculate the total duration per user
3) Sort the list in decreasing order of total_duration per user.
4) Find the median. Assign upper 50% users with weight 1.
5) From the remaining list (50% values), calculate the median and assign the weight 0.5 to users.
6) From the remaining list (25% of total values), calculate the median and assign the weight 0.25 to the users.
7) Do the following calculations:
Reward Pool Balance = 4745 $POLM
$POLM daily reward pool = 4745/365= 13 $POLM
Active users (in past 24 hrs) = 10 active users (with weight 1), 5 active users with weight 0.5 and 2 active users with weight 0.25
Quota for each user = daily reward pool/active users = 13/(101+50.5+20.25) = 13/13 = 1 $POLM
Process stream report:
User A ( weight 1) heard total 10 tracks - 1/10 $POLM per track
User B (weight 0.5) heard 5 tracks - 0.5/5 $POLM per track
User C (weight 0.25) heard 5 tracks (of shorter duration) - 0.25/5 $POLM per track
For Track 1 - user A (with weight 1) heard once, user B (with weight 0.5) heard once, and user C (with state 0.25) heard it two times, hence Track 1 will fetch -- 1/10+0.5/5+ 0.252/5 $POLM = 0.3 $POLM