Explorar el Código

Hide history-resync updates from "All history" (#19435)

* [web] hide history-resync updates from "All history"

* Revert "[web] hide history-resync updates from "All history""

This reverts commit e9d5e7638eabe2baccf36f8c80bb4cd619e383ea.

* filter history resync update in summarizeUpdates

* used isHistoryResyncUpdate for merging

* remove merging for history-resync

* Revert "remove merging for history-resync"

This reverts commit 6ce48bc3f906867a64c0acc12e2dc61c05436c41.

GitOrigin-RevId: 0335eb9c05815fb66188d453a90dd09531504a55
Domagoj Kriskovic hace 2 años
padre
commit
6afb067737

+ 11 - 7
services/project-history/app/js/SummarizedUpdatesManager.js

@@ -189,10 +189,10 @@ function _summarizeUpdates(updates, labels, existingSummarizedUpdates, toV) {
       toV = update.v + 1
     }
 
-    // Skip empty updates (only record their version). Empty updates are
-    // updates that only contain comment operations. We don't have a UI for
+    // Skip empty and history-resync updates (only record their version).
+    // Empty updates are updates that only contain comment operations. We don't have a UI for
     // these yet.
-    if (isUpdateEmpty(update)) {
+    if (isUpdateEmpty(update) || isHistoryResyncUpdate(update)) {
       continue
     }
 
@@ -282,11 +282,8 @@ function _shouldMergeUpdate(update, summarizedUpdate, labels) {
   const updateHasFileOps = update.project_ops.length > 0
   const summarizedUpdateHasTextOps = summarizedUpdate.pathnames.size > 0
   const summarizedUpdateHasFileOps = summarizedUpdate.project_ops.length > 0
-  const isHistoryResync =
-    update.meta.origin &&
-    ['history-resync', 'history-migration'].includes(update.meta.origin.kind)
   if (
-    !isHistoryResync &&
+    !isHistoryResyncUpdate(update) &&
     ((updateHasTextOps && summarizedUpdateHasFileOps) ||
       (updateHasFileOps && summarizedUpdateHasTextOps))
   ) {
@@ -346,3 +343,10 @@ function _mergeUpdate(update, summarizedUpdate) {
 function isUpdateEmpty(update) {
   return update.project_ops.length === 0 && update.pathnames.length === 0
 }
+
+function isHistoryResyncUpdate(update) {
+  return (
+    update.meta.origin?.kind === 'history-resync' ||
+    update.meta.origin?.kind === 'history-migration'
+  )
+}

+ 8 - 48
services/project-history/test/unit/js/SummarizedUpdatesManager/SummarizedUpdatesManagerTests.js

@@ -595,12 +595,12 @@ describe('SummarizedUpdatesManager', function () {
             makeUpdate({
               startTs: 20,
               v: 3,
-              origin: { kind: 'history-resync' },
+              origin: { kind: 'origin-a' },
             }),
             makeUpdate({
               startTs: 30,
               v: 4,
-              origin: { kind: 'history-resync' },
+              origin: { kind: 'origin-a' },
             }),
             makeUpdate({ startTs: 40, v: 5 }),
             makeUpdate({ startTs: 50, v: 6 }),
@@ -617,7 +617,7 @@ describe('SummarizedUpdatesManager', function () {
               endTs: 40,
               fromV: 3,
               toV: 5,
-              origin: { kind: 'history-resync' },
+              origin: { kind: 'origin-a' },
             }),
             makeSummary({ startTs: 0, endTs: 20, fromV: 1, toV: 3 }),
           ]
@@ -687,13 +687,7 @@ describe('SummarizedUpdatesManager', function () {
       describe('history resync updates', function () {
         setupChunks([
           [
-            makeUpdate({
-              startTs: 0,
-              v: 1,
-              origin: { kind: 'history-resync' },
-              projectOps: [{ add: { pathname: 'file1.tex' } }],
-              pathnames: [],
-            }),
+            makeUpdate({ startTs: 0, v: 1 }),
             makeUpdate({
               startTs: 20,
               v: 2,
@@ -709,47 +703,13 @@ describe('SummarizedUpdatesManager', function () {
               v: 3,
               origin: { kind: 'history-resync' },
               projectOps: [{ add: { pathname: 'file4.tex' } }],
-              pathnames: [],
-            }),
-            makeUpdate({
-              startTs: 60,
-              v: 4,
-              origin: { kind: 'history-resync' },
-              projectOps: [],
-              pathnames: ['file1.tex', 'file2.tex', 'file5.tex'],
             }),
-            makeUpdate({
-              startTs: 80,
-              v: 5,
-              origin: { kind: 'history-resync' },
-              projectOps: [],
-              pathnames: ['file4.tex'],
-            }),
-            makeUpdate({ startTs: 100, v: 6, pathnames: ['file1.tex'] }),
+            makeUpdate({ startTs: 60, v: 4 }),
+            makeUpdate({ startTs: 80, v: 5 }),
           ],
         ])
-        expectSummaries('should merge creates and edits', {}, [
-          makeSummary({
-            startTs: 100,
-            endTs: 110,
-            fromV: 6,
-            toV: 7,
-            pathnames: ['file1.tex'],
-          }),
-          makeSummary({
-            startTs: 0,
-            endTs: 90,
-            fromV: 1,
-            toV: 6,
-            origin: { kind: 'history-resync' },
-            pathnames: ['file5.tex'],
-            projectOps: [
-              { add: { pathname: 'file4.tex' }, atV: 3 },
-              { add: { pathname: 'file2.tex' }, atV: 2 },
-              { add: { pathname: 'file3.tex' }, atV: 2 },
-              { add: { pathname: 'file1.tex' }, atV: 1 },
-            ],
-          }),
+        expectSummaries('should skip history-resync updates', {}, [
+          makeSummary({ startTs: 0, endTs: 90, fromV: 1, toV: 6 }),
         ])
       })
     })