LCOV - code coverage report
Current view: top level - server/change - AccountPatchReviewStore.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 2 2 100.0 %
Date: 2022-11-19 15:00:39 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2016 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.change;
      16             : 
      17             : import com.google.auto.value.AutoValue;
      18             : import com.google.common.collect.ImmutableSet;
      19             : import com.google.gerrit.entities.Account;
      20             : import com.google.gerrit.entities.Change;
      21             : import com.google.gerrit.entities.PatchSet;
      22             : import java.util.Collection;
      23             : import java.util.Optional;
      24             : 
      25             : /**
      26             :  * Store for reviewed flags on changes.
      27             :  *
      28             :  * <p>A reviewed flag is a tuple of (patch set ID, file, account ID) and records whether the user
      29             :  * has reviewed a file in a patch set. Each user can easily have thousands of reviewed flags and the
      30             :  * number of reviewed flags is growing without bound. The store must be able handle this data volume
      31             :  * efficiently.
      32             :  *
      33             :  * <p>For a cluster setups with multiple primary nodes the store must replicate the data between the
      34             :  * primary servers.
      35             :  */
      36             : public interface AccountPatchReviewStore {
      37             : 
      38             :   /** Represents patch set id with reviewed files. */
      39             :   @AutoValue
      40           1 :   abstract class PatchSetWithReviewedFiles {
      41             :     public abstract PatchSet.Id patchSetId();
      42             : 
      43             :     public abstract ImmutableSet<String> files();
      44             : 
      45             :     public static PatchSetWithReviewedFiles create(PatchSet.Id id, ImmutableSet<String> files) {
      46           1 :       return new AutoValue_AccountPatchReviewStore_PatchSetWithReviewedFiles(id, files);
      47             :     }
      48             :   }
      49             : 
      50             :   /**
      51             :    * Marks the given file in the given patch set as reviewed by the given user.
      52             :    *
      53             :    * @param psId patch set ID
      54             :    * @param accountId account ID of the user
      55             :    * @param path file path
      56             :    * @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
      57             :    *     already set
      58             :    */
      59             :   boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path);
      60             : 
      61             :   /**
      62             :    * Marks the given files in the given patch set as reviewed by the given user.
      63             :    *
      64             :    * @param psId patch set ID
      65             :    * @param accountId account ID of the user
      66             :    * @param paths file paths
      67             :    */
      68             :   void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths);
      69             : 
      70             :   /**
      71             :    * Clears the reviewed flag for the given file in the given patch set for the given user.
      72             :    *
      73             :    * @param psId patch set ID
      74             :    * @param accountId account ID of the user
      75             :    * @param path file path
      76             :    */
      77             :   void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path);
      78             : 
      79             :   /**
      80             :    * Clears the reviewed flags for all files in the given patch set for all users.
      81             :    *
      82             :    * @param psId patch set ID
      83             :    */
      84             :   void clearReviewed(PatchSet.Id psId);
      85             : 
      86             :   /**
      87             :    * Clears the reviewed flags for all files in all patch sets in the given change for all users.
      88             :    *
      89             :    * @param changeId change ID
      90             :    */
      91             :   void clearReviewed(Change.Id changeId);
      92             : 
      93             :   /**
      94             :    * Find the latest patch set, that is smaller or equals to the given patch set, where at least,
      95             :    * one file has been reviewed by the given user.
      96             :    *
      97             :    * @param psId patch set ID
      98             :    * @param accountId account ID of the user
      99             :    * @return optionally, all files that have been reviewed by the given user that belong to the
     100             :    *     patch set that is smaller or equals to the given patch set
     101             :    */
     102             :   Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId);
     103             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750