<commit_before>package com.dak.duty.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonBackReference;

@Entity
@Table(name = "person_duty")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Getter
@Setter
public class PersonDuty implements Serializable {
   private static final long serialVersionUID = 1L;
   
   @Id
   @SequenceGenerator(name = "person_duty_id_seq", sequenceName = "person_duty_id_seq")
   @GeneratedValue(strategy = GenerationType.AUTO, generator = "person_duty_id_seq")
   @Column(nullable = false)
   private long id;
   
   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name="person_id", nullable=false)
   @JsonBackReference
   private Person person;
   
   @Column(nullable = false)
   @Min(-1)
   @Max(10)
   private Integer preference = -1; // -1 means NEVER pick me ... EVER!
   
   @Column(nullable = false)
   @Min(-1)
   @Max(10)
   private Integer adjustedPreference = null;

   @ManyToOne
   @JoinColumn(name="duty_id", nullable=false)
   private Duty duty;
   
   
   @Transient
   public int getWeightedPreference(){
      return adjustedPreference == null ? preference : adjustedPreference;
   }
   
   @Transient
   public void incrementWeightedPreferenceIfNeeded(){
      if(adjustedPreference < preference){
         adjustedPreference++;
      }
   }
   
   public void setPreference(final Integer preference){
      this.preference = preference;
      setAdjustedPreference(preference);
   }
}<commit_msg>updated incrementWeightedPreferenceIfNeeded() to increment "faster" if difference (pref - adjPref) is higher<commit_after>package com.dak.duty.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonBackReference;

@Entity
@Table(name = "person_duty")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Getter
@Setter
public class PersonDuty implements Serializable {
   private static final long serialVersionUID = 1L;
   
   @Id
   @SequenceGenerator(name = "person_duty_id_seq", sequenceName = "person_duty_id_seq")
   @GeneratedValue(strategy = GenerationType.AUTO, generator = "person_duty_id_seq")
   @Column(nullable = false)
   private long id;
   
   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name="person_id", nullable=false)
   @JsonBackReference
   private Person person;
   
   @Column(nullable = false)
   @Min(-1)
   @Max(10)
   private Integer preference = -1; // -1 means NEVER pick me ... EVER!
   
   @Column(nullable = false)
   @Min(-1)
   @Max(10)
   private Integer adjustedPreference = null;

   @ManyToOne
   @JoinColumn(name="duty_id", nullable=false)
   private Duty duty;
   
   
   @Transient
   public int getWeightedPreference(){
      return adjustedPreference == null ? preference : adjustedPreference;
   }
   
   @Transient
   public void incrementWeightedPreferenceIfNeeded(){
      if(adjustedPreference < preference){
         final int diff = preference - adjustedPreference;
         if(diff >= 7){
            adjustedPreference += 3;
         } else if(diff >= 4){
            adjustedPreference += 2;
         } else {
            adjustedPreference++;
         }
      }
   }
   
   public void setPreference(final Integer preference){
      this.preference = preference;
      setAdjustedPreference(preference);
   }
}
{'fraction_non_alphanumeric': 0.09609874366321358, 'fraction_numerical': 0.00484901917566674, 'mean_word_length': 4.210103329506315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '522458', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1335, 'n_words': 289}