<commit_before>package at.wolfy.observer.pages;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;

import at.wolfy.observer.entities.AudioRecord;
import at.wolfy.observer.sessionstate.AudioRecords;
import at.wolfy.observer.sessionstate.AudioRecords.AudioRecordDay;
import at.wolfy.observer.sessionstate.AudioRecords.AudioRecordHour;
import at.wolfy.observer.streams.AttachmentStreamResponse;
import at.wolfy.observer.streams.AttachmentStreamResponse.ContentType;

public class RecordsList {

	private SimpleDateFormat dateFormatterDay = new SimpleDateFormat("dd.MM.yyyy");
	private SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy HH:mm");
	
	@SessionState
	private AudioRecords audioRecords;
	
	@Property
	private AudioRecordDay audioRecordDay;
	
	@Property
	private AudioRecordHour audioRecordHour;
	
	@Property 
	private AudioRecord audioRecord;
	
	public boolean isShowAudioRecordDays() {
		return audioRecords.getSelectedDay() == null;
	}
	
	public boolean isShowAudioRecordHours() {
		return !isShowAudioRecordDays() && audioRecords.getSelectedHour() == null;
	}
	
	public boolean isShowAudioRecords() {
		return !isShowAudioRecordDays() && !isShowAudioRecordHours();
	}
	
	public List<AudioRecordDay> getAudioRecordDays() {
		return audioRecords.getAudioRecordDays();
	}
	
	public List<AudioRecordHour> getAudioRecordHours() {
		if (audioRecords.getSelectedDay() == null) {
			return Collections.emptyList();
		}
		return audioRecords.getSelectedDay().getAudioRecordHours();
	}
	
	public List<AudioRecord> getAudioRecords() {
		if (audioRecords.getSelectedHour() == null) {
			return Collections.emptyList();
		}
		return audioRecords.getSelectedHour().getAudioRecords();
	}
	
	public String getAudioRecordDayName() throws ParseException {
		return dateFormatterDay.format(audioRecordDay.getStart());
	}
	
	public String getAudioRecordHourName() throws ParseException {
		return dateFormatter.format(audioRecordHour.getStart());
	}
	
	public String getAudioRecordName() throws ParseException {
		return dateFormatter.format(audioRecord.getStart());
	}
	
	public int getAudioRecordDayIndex() {
		return audioRecords.getAudioRecordDays().indexOf(audioRecordDay);
	}
	
	public int getAudioRecordHourIndex() {
		return audioRecords.getSelectedDay().getAudioRecordHours().indexOf(audioRecordHour);
	}
	
	public int getAudioRecordIndex() {
		return audioRecords.getSelectedHour().getAudioRecords().indexOf(audioRecord);
	}
	
	public List<AudioRecord> getAudioRecordDayRecords() {
		List<AudioRecord> ars = new LinkedList<>();
		for (AudioRecordHour arh: audioRecordDay.getAudioRecordHours()) {
			ars.addAll(arh.getAudioRecords());
		}
		return ars;
	}
	
	public List<AudioRecord> getAudioRecordHourRecords() {
		return audioRecordHour.getAudioRecords();
	}
	
	@OnEvent(component="audioRecordDaySelectLink")
	public void selectDay(int index) {
		AudioRecordDay selected = audioRecords.getAudioRecordDays().get(index);
		audioRecords.setSelectedDay(selected);
	}
	
	@OnEvent(component="audioRecordHourSelectLink")
	public void selectHour(int index) {<commit_msg>reduced AudioRecords for improved displaying<commit_after>package at.wolfy.observer.pages;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;

import at.wolfy.observer.entities.AudioRecord;
import at.wolfy.observer.sessionstate.AudioRecords;
import at.wolfy.observer.sessionstate.AudioRecords.AudioRecordDay;
import at.wolfy.observer.sessionstate.AudioRecords.AudioRecordHour;
import at.wolfy.observer.streams.AttachmentStreamResponse;
import at.wolfy.observer.streams.AttachmentStreamResponse.ContentType;

public class RecordsList {

	private SimpleDateFormat dateFormatterDay = new SimpleDateFormat("dd.MM.yyyy");
	private SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy HH:mm");
	
	@SessionState
	private AudioRecords audioRecords;
	
	@Property
	private AudioRecordDay audioRecordDay;
	
	@Property
	private AudioRecordHour audioRecordHour;
	
	@Property 
	private AudioRecord audioRecord;
	
	public boolean isShowAudioRecordDays() {
		return audioRecords.getSelectedDay() == null;
	}
	
	public boolean isShowAudioRecordHours() {
		return !isShowAudioRecordDays() && audioRecords.getSelectedHour() == null;
	}
	
	public boolean isShowAudioRecords() {
		return !isShowAudioRecordDays() && !isShowAudioRecordHours();
	}
	
	public List<AudioRecordDay> getAudioRecordDays() {
		return audioRecords.getAudioRecordDays();
	}
	
	public List<AudioRecordHour> getAudioRecordHours() {
		if (audioRecords.getSelectedDay() == null) {
			return Collections.emptyList();
		}
		return audioRecords.getSelectedDay().getAudioRecordHours();
	}
	
	public List<AudioRecord> getAudioRecords() {
		if (audioRecords.getSelectedHour() == null) {
			return Collections.emptyList();
		}
		return audioRecords.getSelectedHour().getAudioRecords();
	}
	
	public String getAudioRecordDayName() throws ParseException {
		return dateFormatterDay.format(audioRecordDay.getStart());
	}
	
	public String getAudioRecordHourName() throws ParseException {
		return dateFormatter.format(audioRecordHour.getStart());
	}
	
	public String getAudioRecordName() throws ParseException {
		return dateFormatter.format(audioRecord.getStart());
	}
	
	public int getAudioRecordDayIndex() {
		return audioRecords.getAudioRecordDays().indexOf(audioRecordDay);
	}
	
	public int getAudioRecordHourIndex() {
		return audioRecords.getSelectedDay().getAudioRecordHours().indexOf(audioRecordHour);
	}
	
	public int getAudioRecordIndex() {
		return audioRecords.getSelectedHour().getAudioRecords().indexOf(audioRecord);
	}
	
	public List<AudioRecord> getAudioRecordDayRecords() {
		List<AudioRecord> ars = new LinkedList<>();
		Integer maxVolume;
		for (AudioRecordHour arh: audioRecordDay.getAudioRecordHours()) {
			maxVolume = 0;
			for (AudioRecord ar : arh.getAudioRecords()) {
				for (Integer vol : ar.getVolumes()) {
					maxVolume = Math.max(0, vol);
				}
				AudioRecord reducedAr = new AudioRecord();
				reducedAr.setStart(ar.getStart());
				reducedAr.setVolumes(asList(maxVolume));
				ars.add(reducedAr);
			}
		}
		return ars;
	}
	
	private List<Integer> asList(Integer value) {
		return Arrays.asList(new Integer[]{value});
	}
	
	public List<AudioRecord> getAudioRecordHourRecords() {
		return audioRecordHour.getAudioRecords();
	}
	
	@OnEvent(component="audioRecordDaySelectLink")
	public void selectDay(int index) {
		AudioRecordDay selected = audioRecords.getAudioRecordDays().get(index);
		audioRecords.setSelectedDay(selected);
	}
	
	@OnEvent(component="audioRecordHourSelectLink")
	public void selectHour(int index) {
{'fraction_non_alphanumeric': 0.10292932007524859, 'fraction_numerical': 0.0013437248051599033, 'mean_word_length': 6.13614573346117, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '412299', 'n_tokens_mistral': 2381, 'n_tokens_neox': 2153, 'n_words': 400}