 function buildRows(historyKey: TGKey): ResultRow[] {
   const { slot, date } = TGKey.parse(historyKey);
   let players: UserKey[] = Attendance.players(historyKey);
 
   if (players.length === 0) {
     const history = Store.read<{ scores: TGScore[] }>(TGKey.toHistoryPath(historyKey));
     if (history?.scores) {
       players = [...new Set(history.scores.map((s: TGScore) => s.userKey))];
     }
   }
 
   const weekKey    = WRank.weekKey(new Date(date));
   const addedUsers = new Set<UserKey>();
   const rows: ResultRow[] = [];
 
   for (const userKey of players) {
     const chars = CharacterRegistry.forUser(userKey);
 
     for (const char of chars) {
       const score = Score.get({ character: char, slot, historyKey });
       if (!score) continue;
 
       const wrEntry  = WRank.entry(char.name, char.nation, weekKey);
       const position = score.wRankAtSubmission
         ? {
             currentRank:  score.wRankAtSubmission.rank,
             previousRank: score.wRankAtSubmission.rank - score.wRankAtSubmission.delta,
           }
         : wrEntry
           ? { currentRank: wrEntry.currentRank, previousRank: wrEntry.previousRank }
           : undefined;
 
       rows.push({
         character:   char,
         score,
         position,
         leavesCount: Leaves.countForChar({ characterName: char.name }),
       });
       addedUsers.add(userKey);
       break;
     }
 
     if (!addedUsers.has(userKey)) {
       const history = Store.read<{ scores: TGScore[] }>(TGKey.toHistoryPath(historyKey));
       const score   = history?.scores.find((s: TGScore) => s.userKey === userKey);
       if (score) {
         const foundChar = CharacterRegistry.find(score.characterName);
         const classKey  = (typeof score.class === "object"
           ? (score.class as any)?.key
           : score.class) as ClassKey;
         const char: Character = foundChar ?? {
           name:     score.characterName,
           class:    CLASSES[classKey] ?? { key: classKey, name: classKey, shortName: classKey },
           level:    0,
           nation:   score.nation,
           ownerKey: score.userKey,
         };
         const wrEntry  = WRank.entry(char.name, char.nation, weekKey);
         const position = score.wRankAtSubmission
           ? {
               currentRank:  score.wRankAtSubmission.rank,
               previousRank: score.wRankAtSubmission.rank - score.wRankAtSubmission.delta,
             }
           : wrEntry
             ? { currentRank: wrEntry.currentRank, previousRank: wrEntry.previousRank }
             : undefined;
 
         rows.push({ character: char, score, position, leavesCount: 0 });
         addedUsers.add(userKey);
       }
     }
   }
 
   return rows;
 }