<commit_before>package com.unidev.polyinsights.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.HashMap;
import java.util.Map;

@Document(collection = "tenant")
public class Tenant {

    @Id
    private String tenant;

    private Map<String, InsightType> types;

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Tenant{");
        sb.append("tenant='").append(tenant).append('\'');
        sb.append(", types=").append(types);
        sb.append('}');
        return sb.toString();
    }

    public void addType(InsightType type) {
        if (types == null) {
            types = new HashMap<>();
        }
        types.put(type.getName(), type);
    }
<commit_msg>Added method for fetching insight by tenant name<commit_after>package com.unidev.polyinsights.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Document(collection = "tenant")
public class Tenant {

    @Id
    private String tenant;

    private Map<String, InsightType> types;

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Tenant{");
        sb.append("tenant='").append(tenant).append('\'');
        sb.append(", types=").append(types);
        sb.append('}');
        return sb.toString();
    }

    public void addType(InsightType type) {
        if (types == null) {
            types = new HashMap<>();
        }
        types.put(type.getName(), type);
    }

    public Optional<InsightType> fetchInsight(String type) {
        if (types == null) {
            return Optional.empty();
        }
        if (!types.containsKey(type)) {
            return Optional.empty();
        }
        InsightType insightType = types.get(type);
        return Optional.of(insightType);
    }

{'fraction_non_alphanumeric': 0.1347410759175465, 'fraction_numerical': 0.0, 'mean_word_length': 2.7547169811320753, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '1566082', 'n_tokens_mistral': 572, 'n_tokens_neox': 572, 'n_words': 127}