justinpark commented on code in PR #32608:
URL: https://github.com/apache/superset/pull/32608#discussion_r1991833541


##########
superset-frontend/src/views/CRUD/utils.tsx:
##########
@@ -223,10 +224,14 @@ export const getRecentActivityObjs = (
 ) =>
   SupersetClient.get({ endpoint: recent }).then(recentsRes => {
     const res: any = {};
+    const distinctRes = lruCache<RecentActivity>(6);
+    recentsRes.json.result.reverse().forEach((record: RecentActivity) => {
+      distinctRes.set(record.item_url, record);
+    });
     return getFilteredChartsandDashboards(addDangerToast, filters).then(
       ({ other }) => {
         res.other = other;
-        res.viewed = recentsRes.json.result;
+        res.viewed = distinctRes.values().reverse();

Review Comment:
   The API returns the latest accesses in reverse chronological order. (i.e. 
[2025-03-10, 2025-03-09, 2025-03-07, ...]) For an LRU cache, access records 
need to be stored in chronological order. Therefore, the API list must be 
reversed to maintain a record of accesses in chronological order. After that, 
since the final LRU cache list has the most recent entries placed at the end, 
it needs to be reversed again to position the latest entries at the front.
   This two-step reversal process is an algorithmically correct approach.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to