Skip to content

Commit

Permalink
summary3() does not compute...
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed Jul 2, 2024
1 parent 67eefca commit a211e29
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
4 changes: 3 additions & 1 deletion javasrc/org/hd/d/statsHouse/feedHits/GenerateSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ public static MIDITune summary2(final List<String> dirnames) throws IOException
*/
public static MIDITune summary3(final List<String> dirnames) throws IOException
{
final FeedStatusBlocks fsbs = FeedStatusBlocks.loadStatusByHourFromDirs(dirnames);
final FeedStatusBlocks fsbs = FeedStatusBlocks.loadStatusByUAFromDirs(dirnames);

if(true) { throw new RuntimeException("COMPUTER SEZ NO"); }

// Total number of distinct hours to sonify; 24 summary hours for each block.
final int nTotalHours = fsbs.blocks().size() * 24;
Expand Down
40 changes: 38 additions & 2 deletions javasrc/org/hd/d/statsHouse/feedHits/data/FeedStatusBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public record FeedStatusBlocks(List<FeedStatusBlock> blocks)
public static final String INTERVAL_DAYS_FILENAME = "intervalDays.txt";
/**File containing summary by-hour status data for the data block directory.. */
public static final String STATUS_BY_HOUR_FILENAME = "feedStatusByHour.log";
/**File containing summary by-UA status data for the data block directory.. */
public static final String STATUS_BY_UA_FILENAME = "feedStatusByUA.log";

/**Construct FeedStatusBlocks from an ordered list of directory names.
/**Construct by-hour FeedStatusBlocks from an ordered list of directory names.
* @throws IOException
*/
public static FeedStatusBlocks loadStatusByHourFromDirs(final List<String> dirnames) throws IOException
Expand All @@ -62,7 +64,7 @@ public static FeedStatusBlocks loadStatusByHourFromDirs(final List<String> dirna
final FeedStatusBlock fsb = FeedStatusBlock.parseRecords(nDays,
new FileReader(sbh, FeedStatus.CHARSET));

// Do a little bit of validation of by-hour records.
// Some validation of by-hour records.
if(fsb.records().size() < 24)
{ throw new IOException("too few records in "+STATUS_BY_HOUR_FILENAME+" file in directory: " + dn); }
if(!"00".equals(fsb.records().get(0).index()) || !"23".equals(fsb.records().get(23).index()))
Expand All @@ -71,6 +73,40 @@ public static FeedStatusBlocks loadStatusByHourFromDirs(final List<String> dirna
blocks.add(fsb);
}

return(new FeedStatusBlocks(blocks));
}

/**Construct by-UA FeedStatusBlocks from an ordered list of directory names.
* @throws IOException
*/
public static FeedStatusBlocks loadStatusByUAFromDirs(final List<String> dirnames) throws IOException
{
Objects.requireNonNull(dirnames);
final List <FeedStatusBlock> blocks = new ArrayList<>(dirnames.size());

for(final String dn : dirnames)
{
final File d = new File(dn);
if(!d.isDirectory()) { throw new IOException("not a directory: " + dn); }

final File id = new File(d, INTERVAL_DAYS_FILENAME);
if(!id.isFile()) { throw new IOException("no "+INTERVAL_DAYS_FILENAME+" file in directory: " + dn); }
final File sbh = new File(d, STATUS_BY_UA_FILENAME);
if(!sbh.isFile()) { throw new IOException("no "+STATUS_BY_UA_FILENAME+" file in directory: " + dn); }

final int nDays = Integer.parseInt(Files.readString(id.toPath(), FeedStatus.CHARSET).trim(), 10);
final FeedStatusBlock fsb = FeedStatusBlock.parseRecords(nDays,
new FileReader(sbh, FeedStatus.CHARSET));

// Some validation of by-UA records.
if(fsb.records().size() < 1)
{ throw new IOException("too few records in "+STATUS_BY_UA_FILENAME+" file in directory: " + dn); }
if(!"ALL".equals(fsb.records().get(0).index()))
{ throw new IOException("unexpected records in "+STATUS_BY_UA_FILENAME+" file in directory: " + dn); }

blocks.add(fsb);
}

return(new FeedStatusBlocks(blocks));
}
}

0 comments on commit a211e29

Please sign in to comment.