<commit_before>/*
 * Copyright (c) 2017 mikan
 */

package com.github.javatrainingcourse.obogmanager.domain.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.UUID;

/**
 * パスワードリセット要求のトークンを提供するエンティティです。
 * トークンの有効期限はとりあえず24時間です。
 *
 * @author mikan
 * @since 0.1
 */
@Entity
@Table(name = "password_resets")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PasswordResetRequest {

    @Id
    @Column
    @Getter
    private String token;

    @JoinColumn(nullable = false)
    @ManyToOne(cascade = CascadeType.DETACH)
    @Getter
    private Membership membership;

    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date generatedTime;

    public PasswordResetRequest(Membership membership) {
        token = UUID.randomUUID().toString();
        generatedTime = new Date();
        this.membership = membership;
    }

    public boolean isExpired() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime generated = LocalDateTime.ofInstant(generatedTime.toInstant(), ZoneId.systemDefault());
        return now.isAfter(generated.plusDays(1));
    }
}<commit_msg>refs #2 change column length for fit to mb4 MySQL<commit_after>/*
 * Copyright (c) 2017 mikan
 */

package com.github.javatrainingcourse.obogmanager.domain.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.UUID;

/**
 * パスワードリセット要求のトークンを提供するエンティティです。
 * トークンの有効期限はとりあえず24時間です。
 *
 * @author mikan
 * @since 0.1
 */
@Entity
@Table(name = "password_resets")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PasswordResetRequest {

    @Id
    @Column(length = 64)
    @Getter
    private String token;

    @JoinColumn(nullable = false)
    @ManyToOne(cascade = CascadeType.DETACH)
    @Getter
    private Membership membership;

    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date generatedTime;

    public PasswordResetRequest(Membership membership) {
        token = UUID.randomUUID().toString();
        generatedTime = new Date();
        this.membership = membership;
    }

    public boolean isExpired() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime generated = LocalDateTime.ofInstant(generatedTime.toInstant(), ZoneId.systemDefault());
        return now.isAfter(generated.plusDays(1));
    }
}
{'fraction_non_alphanumeric': 0.10397326401782399, 'fraction_numerical': 0.008169327887114742, 'mean_word_length': 3.970479704797048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6101912', 'n_tokens_mistral': 907, 'n_tokens_neox': 877, 'n_words': 174}