Feature - Implemented Ability to specify a range of session logs to open.

icon315

Member
Not sure if it's feasible it is but having

Code:
string [int] session_logs(string name ,int days )
Instead be:
Code:
string [int] session_logs(string name ,int startday, int endday )


Basically what this would do is make it so that you can open the specific logs you need. That way you go from opening logs you need+all the logs after, to opening just the logs you need. Trying to open an old log atm, as an example let's say 3 100-day old logs, makes it so you open 100 logs. This way you only open 3.
 

ckb

Minion
Staff member
I am bumping this request because it would be super helpful for parsing past logs and runs. I tried to parse a run from a few months ago, but the only way was to either load all logs since them (and run out of memory) or rename the logs files manually to trick Mafia.
 

Darzil

Developer
Just because I'm stupid, what system are you using there to convert int startday into a date ?

Or maybe we can just do string name, string date (YYYYMMDD) and return that log, and let handling multiple be a script issue?
 
Last edited:

fronobulax

Developer
Staff member
I am bumping this request because it would be super helpful for parsing past logs and runs. I tried to parse a run from a few months ago, but the only way was to either load all logs since them (and run out of memory) or rename the logs files manually to trick Mafia.

Moving logs into a different directory should also work.
 

fronobulax

Developer
Staff member
Just because I'm stupid, what system are you using there to convert int startday into a date ?

Or maybe we can just do string name, string date (YYYYMMDD) and return that log, and let handling multiple be a script issue?

I don't think suggesting the start and end as ints got a lot of thought.

Whatever we do I would require YYYYMMDD and anything that was not valid generated a warning and returned null or empty.

Heeheehee wrote an ash datelib circa 2010 which will let a scripter add or subtract dates so if we added the ability to fetch a single specific log the scripter could generate names as needed.

I'm thinking the easiest might be a start date (string) and then an int days, which could be plus or minus. The end date can be calculated and then any existing logs within the interval could be processed. This puts most of the date calculations in Java rather than ash.
 

icon315

Member
Edit: fronobulax beat me to it. I need to start typing faster.

The naming convention wasn't the best, it's not specific dates, per se, it's just a range. So more like:

PHP:
string [int] session_logs(string name ,int firstRange , int secondRange);

but I guess the way you described it could be something like:
PHP:
string [int] session_logs(string name ,string startDate, int range)
startDate would use YYYYMMDD, then it'd just return that and the following ones based on range. We could use the old version to figure out where ascensions start and end, but once that is done we'd use this so that

PHP:
string[int,int] ascensionArray; //Parsing all the files and would be done (hopefully) with another script so that this script never has to have that many files open. Formatted something like 


string getAscesion(int foo)
{
 //Do the stuff to find start and length of the ascension here
  session_logs("icon315", ascensionStart, ascensionLength);
}
 
Last edited:

ckb

Minion
Staff member
Yea, I am not picky about how it would be done, just that it would be possible so I could weave it into my script.
 

fronobulax

Developer
Staff member
I am mildly interested in doing this. If someone beats me to it, fine. Polite, gentle nudges that remind me of my interest will keep me on track.

My initial goal is

string [int] session_logs(string name, string baseDate, int range)

where name is the name of the character, baseDate is a string date of the form YYYYMMDD and range is the number of days from the baseDate to be considered.

Range plus one log files will be considered. The file names for consideration will be generated by adding (or subtracting) days to the baseDate. If an appropriately named text file is not found then a gz file will be considered. Only the sessions directory will be searched (unless the existing code is doing something different). Errors may be logged but are expected to return an empty map.

This isn't completely trivial because the code that generates the names and the code that reads and processes the files (by superficial inspection) is intertwined, so it will need to be refactored first.

I am almost certainly lazy enough to only test this lightly and trust the community will be kind with bug reports.
 

fronobulax

Developer
Staff member
r19030

string [int] session_logs(string name, string baseDate, int range)

Very little error checking.

Using the map index, I believe the logs are reported in ascending chronological order but that is a belief, not a guarantee.

Lightly tested so let me know what needs to be less lightly tested and then fixed.
 

icon315

Member
Would it be possible to make it so that session logs are keyed using the session log's name or date (YYYYMMDD) instead of days from the initial session log. That way it's easier to reference back to exact session log.
 

fronobulax

Developer
Staff member
Would it be possible to make it so that session logs are keyed using the session log's name or date (YYYYMMDD) instead of days from the initial session log. That way it's easier to reference back to exact session log.

Using an integer count was a deliberate choice to be conceptually compatible with the older form of session_logs. Not to mention it was part of the Feature Request :) I suppose that could be abandoned or session_log overloaded again, to return a map keyed by a string but...

If you want a specific log just call the existing function with a count of 0.

There is an ash datelib that, if my memory is correct, supports addition to a date string so you could just take the int, add it to the base and then see if the resulting YYYYMMDD is the one you are looking for. So I could argue that this is merely a convenience.

Any other opinions about whether it is worth doing?
 

heeheehee

Developer
Staff member
There is an ash datelib that, if my memory is correct, supports addition to a date string so you could just take the int, add it to the base and then see if the resulting YYYYMMDD is the one you are looking for. So I could argue that this is merely a convenience.

You could probably just datediff("20181211", today_to_string()) to get the int argument.

(I looked at that library for the first time in probably years, just now... some of the formatting makes me twitch.)
 
Top