Browse Source

Reports: read hourly report_HH.db files

la_mojo now writes one report database per local hour into the day
folder (data/reports/YYYY/MM/DD/report_HH.db) instead of a single
report.db. Days recorded earlier keep their report.db; a day during the
upgrade has both.

- lib/php/db/report_files.php (loaded by ajax_asm.php, added to
  files.list): lists a day's report files and maps ids. Row ids are per
  file, so ids sent to the browser are global:
      id = slot * 10000000 + rowid   (slot 0..23 = hour, 24 = legacy report.db)
  The JavaScript treats ids as opaque, so no JavaScript changes are needed.
  Report files are never created by the web UI (existence is checked).
- getHistoryDay: sessions and "Events by Hours" from all files of the day
  (legacy file split by hour as before, one node per hourly file).
- getHistoryEvents, getBubbleAnalysis, setPermanentBubbles: BID..EID range
  resolved to its file.
- getVideoInfo, getPictureInfo, getFrames: event/video ids resolved to
  their file; video ids returned as global ids.
- getStatus (live log): newest hourly file of the newest day; LSID from a
  previous hour/day restarts at the beginning of the new file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/1/head
Claude 2 hours ago
parent
commit
16534fd591
Failed to extract signature
  1. 1
      files.list
  2. 1
      lib/ajax_asm.php
  3. 8
      lib/controller/getBubbleAnalysis.php
  4. 7
      lib/controller/getFrames.php
  5. 125
      lib/controller/getHistoryDay.php
  6. 10
      lib/controller/getHistoryEvents.php
  7. 9
      lib/controller/getPictureInfo.php
  8. 25
      lib/controller/getStatus.php
  9. 14
      lib/controller/getVideoInfo.php
  10. 8
      lib/controller/setPermanentBubbles.php
  11. 74
      lib/php/db/report_files.php

1
files.list

@ -5711,6 +5711,7 @@
./lib/php/db/user_class.php
./lib/php/db/VS_Object_class.php
./lib/php/db/SQLite_Class.php
./lib/php/db/report_files.php
./lib/php/db/VS_Tree_class.php
./lib/php/db/language_class.php
./lib/php/db/external.php

1
lib/ajax_asm.php

@ -16,6 +16,7 @@ if( $TT_123[0] == '4' ){
};
*/
require_once( 'php/db/SQLite_Class.php');
require_once( 'php/db/report_files.php'); // hourly report_HH.db files + global report ids
$DATABASE = new SQLite_DB( $SYSPath . '/lib/controller/data/mysqlitedb.db');

8
lib/controller/getBubbleAnalysis.php

@ -75,9 +75,11 @@
};
if( $UID > 1 && $DTS ){
$DS = date("Y/m/d", $DTS );
$QS = "SELECT * FROM `events` WHERE ( `evt_type`=13 OR `evt_type`=14 ) AND `id`>={$BID} AND `id`<={$EID} ORDER BY `ts` ASC, `ts_ms` ASC";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
$LREC = $ZIZI->Query( $QS );
// BID/EID are global ids of one report file (see report_files.php)
list( $SLOT, $RBID, $REID ) = reportResolveRange( $BID, $EID );
$QS = "SELECT * FROM `events` WHERE ( `evt_type`=13 OR `evt_type`=14 ) AND `id`>={$RBID} AND `id`<={$REID} ORDER BY `ts` ASC, `ts_ms` ASC";
$ZIZI = reportOpenSlot( $DS, $SLOT );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
if( count( $LREC ) ){
foreach( $LREC as $REC ){
$bid = serchInBubbles( $REC );

7
lib/controller/getFrames.php

@ -8,9 +8,10 @@
if( isset( $_GET['sf'] ) ) $START_FRAME = intval( $_GET['sf'] );
if( $VID && $DTS ){
$DS = date("Y/m/d", $DTS );
$QS = "SELECT * FROM `videos` WHERE `id` = {$VID}";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
$LREC = $ZIZI->Query( $QS );
// VID is a global video id (see report_files.php)
$QS = "SELECT * FROM `videos` WHERE `id` = " . reportRawId( $VID );
$ZIZI = reportOpenSlot( $DS, reportSlotOf( $VID ) );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
if( count( $LREC ) ){
$Data = $LREC[0];

125
lib/controller/getHistoryDay.php

@ -13,6 +13,7 @@
$D = date("d", $DTS );
$DS = date("Y/m/d", $DTS );
$NONO = '';
$EVEVE = '';
$MUMU = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/stat.db' );
$QS = "SELECT * FROM `days` WHERE `year`={$Y} AND `month`={$M} AND `day`={$D}";
$LOLO = $MUMU->Query( $QS );
@ -23,71 +24,83 @@
$S = intval( $LOLO[0]['session_count'] );
$V = intval( $LOLO[0]['videos_count'] );
$E = intval( $LOLO[0]['evt_count'] );
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/' . $DS . '/report.db' );
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$BID = 0;
$EID = 0;
$BTM = 0;
$JIGA = array();
foreach( $NDD as $N ){
if( $st_ignore && $N['evt_type']!=52 ) continue;
if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
if( $N['evt_type']==52 ) {
$DH = 0;
$BID = intval( $N['id'] );
$BTM = date( "H:i:s", $N['ts'] );
} else {
$DH = 1;
$EID = intval( $N['id'] );
// One report file per hour (report_HH.db) and/or the legacy day report.db - ids are global (see report_files.php)
$JIGA = array();
$SIGA = array();
foreach( reportDayFiles( $DS ) as $SLOT => $RFILE ){
$ZIZI = new SQLite_DB( $RFILE, SQLITE3_OPEN_READWRITE );
// Sessions (START=52, END=53/54) - with hourly files a session never spans two files
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 ) ORDER BY `id`";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$BID = 0;
$EID = 0;
$BTM = 0;
foreach( $NDD as $N ){
if( $st_ignore && $N['evt_type']!=52 ) continue;
if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
if( $N['evt_type']==52 ) {
$DH = 0;
$BID = reportEncodeId( $SLOT, $N['id'] );
$BTM = date( "H:i:s", $N['ts'] );
} else {
$DH = 1;
$EID = reportEncodeId( $SLOT, $N['id'] );
};
if( $st_ignore == false && $DH == 1 ){
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
};
if( $st_ignore == false && $DH == 1 ){
if( $st_ignore == false && $DH == 0 ){
// Session still open in this file (ongoing, or the file was not closed) - up to the end of the file
$EID = reportEncodeId( $SLOT, REPORT_RAW_ID_MAX );
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
};
if( $DH == 0 ){
//Ongoing Event goes next day - must catch up
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
// Events by hours
if( $SLOT == REPORT_LEGACY_SLOT ){
// Legacy day file: split by hour
$QS = "SELECT DISTINCT `ts`/3600 AS JUJA FROM `events`";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$EID = intval( $NDD[0]['id'] );
} else {
$EID = 1000000000;//Infinity
foreach( $NDD as $N ){
$BTS = intval($N['JUJA'])*3600;
$DADA = date( "H:i", $BTS );
$ETS = $BTS+3600;
$BID = 0;
$EID = 0;
$QS="SELECT `id` FROM `events` WHERE `ts`>({$BTS}-1) LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $BID = $KK[0]['id'];
$QS="SELECT `id` FROM `events` WHERE `ts`<({$ETS}-1) ORDER BY `id` DESC LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $EID = $KK[0]['id']; else $EID = $BID;
if( $BID && $EID ){
$BID = reportEncodeId( $SLOT, $BID );
$EID = reportEncodeId( $SLOT, $EID );
$SIGA[] = array( 'k' => $BTS, 'n' => "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }" );
};
};
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
if( count( $JIGA ) ){
$NONO = "{ text: 'Sessions', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
} else {
$NONO = "{ text: 'No Sessions', leaf: true }";
// Hourly file: one node for the whole file
$KK = $ZIZI->Query( "SELECT MIN(`id`) AS `b`, MAX(`id`) AS `e`, MIN(`ts`) AS `t` FROM `events`" );
if( count( $KK ) && intval( $KK[0]['b'] ) ){
$BID = reportEncodeId( $SLOT, $KK[0]['b'] );
$EID = reportEncodeId( $SLOT, $KK[0]['e'] );
$DADA = sprintf( "%02d:00", $SLOT );
$SIGA[] = array( 'k' => intval( $KK[0]['t'] ), 'n' => "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }" );
};
};
};
$QS = "SELECT DISTINCT `ts`/3600 AS JUJA FROM `events`";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$SIGA = array();
foreach( $NDD as $N ){
$BTS = intval($N['JUJA'])*3600;
$DADA = date( "H:i", $BTS );
$ETS = $BTS+3600;
$BID = 0;
$EID = 0;
$QS="SELECT `id` FROM `events` WHERE `ts`>({$BTS}-1) LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $BID = $KK[0]['id'];
$QS="SELECT `id` FROM `events` WHERE `ts`<({$ETS}-1) ORDER BY `id` DESC LIMIT 1";
$KK = $ZIZI->Query( $QS );
if( count( $KK ) ) $EID = $KK[0]['id']; else $EID = $BID;
if( $BID && $EID ){
$SIGA[] = "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
};
$EVEVE = "{ text: 'Events by Hours', leaf: false, expanded: true, children:[". implode( ",", $SIGA ) . "]}";
if( count( $JIGA ) ){
$NONO = "{ text: 'Sessions', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
} else {
$NONO = "{ text: 'No Sessions', leaf: true }";
};
if( count( $SIGA ) ){
usort( $SIGA, function( $A, $B ){ return $A['k'] - $B['k']; } );
$EVEVE = "{ text: 'Events by Hours', leaf: false, expanded: true, children:[". implode( ",", array_column( $SIGA, 'n' ) ) . "]}";
};
};
if( $NONO=='' ) $NONO = "{ text: 'No Sessions', leaf: true }";

10
lib/controller/getHistoryEvents.php

@ -15,14 +15,16 @@
foreach( $result as $R ) $NodeNames[$R['id']] = $R['name'];
$DS = date("Y/m/d", $DTS );
//$QS = "SELECT `events`.*, `events_2_videos`.* FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) WHERE `events`.`id` >= {$BID} AND `events`.`id`<={$EID} ORDER BY `ts` ASC, `ts_ms` ASC";
$QS = "SELECT `events`.*, `events_2_videos`.`video_id`, `events_2_pictures`.`picture_id` FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) LEFT JOIN `events_2_pictures` ON( `events`.`id` = `events_2_pictures`.`evt_id` ) WHERE `events`.`id`>={$BID} AND `events`.`id`<={$EID} ORDER BY `events`.`ts` ASC, `events`.`ts_ms` ASC";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
// BID/EID are global ids of one report file (see report_files.php)
list( $SLOT, $RBID, $REID ) = reportResolveRange( $BID, $EID );
$QS = "SELECT `events`.*, `events_2_videos`.`video_id`, `events_2_pictures`.`picture_id` FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) LEFT JOIN `events_2_pictures` ON( `events`.`id` = `events_2_pictures`.`evt_id` ) WHERE `events`.`id`>={$RBID} AND `events`.`id`<={$REID} ORDER BY `events`.`ts` ASC, `events`.`ts_ms` ASC";
$ZIZI = reportOpenSlot( $DS, $SLOT );
//$LREC = array_reverse( $ZIZI->Query( $QS ) );
$LREC = $ZIZI->Query( $QS );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
$Data['log'] = array();
//date_default_timezone_set('America/New_York');
foreach( $LREC as $REC ){
$CR['id'] = intval( $REC['id'] );
$CR['id'] = reportEncodeId( $SLOT, $REC['id'] );
$CR['node_id'] = intval( $REC['node_id'] );
$CR['node_name'] = $NodeNames[$CR['node_id']];
$CR['rts'] = $DTS;

9
lib/controller/getPictureInfo.php

@ -6,9 +6,12 @@
if( $EID ){
$DS = date("Y/m/d", $DTS );
//$QS = "SELECT * FROM `videos` WHERE `id` = {$VID}";
$QS = "SELECT `pictures`.`media_stream_id`, `pictures`.`md5`, `pictures`.`ext` FROM `events_2_pictures` LEFT JOIN `pictures` ON( `pictures`.`id` = `events_2_pictures`.`picture_id` ) WHERE `events_2_pictures`.`evt_id`={$EID}";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
$LREC = $ZIZI->Query( $QS );
// ID is a global event id (see report_files.php)
$SLOT = reportSlotOf( $EID );
$REID = reportRawId( $EID );
$QS = "SELECT `pictures`.`media_stream_id`, `pictures`.`md5`, `pictures`.`ext` FROM `events_2_pictures` LEFT JOIN `pictures` ON( `pictures`.`id` = `events_2_pictures`.`picture_id` ) WHERE `events_2_pictures`.`evt_id`={$REID}";
$ZIZI = reportOpenSlot( $DS, $SLOT );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
if( count( $LREC ) ){
$Pack = array();
$Pack['pictures'] = array();

25
lib/controller/getStatus.php

@ -22,18 +22,33 @@
$STR = $STATS->Query( $QS );
if( count( $STR ) ){
$DTS = sprintf("%04d/%02d/%02d", intval($STR[0]['year']), intval($STR[0]['month']), intval($STR[0]['day']));
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DTS.'/report.db');
$QS = "SELECT `id` FROM `events` WHERE `id` > {$LLID} LIMIT 1";
$CH = $ZIZI->Query( $QS );
// Newest report file of the newest day: last hourly report_HH.db (or legacy report.db)
// LSID is the global id of the last event the browser has (see report_files.php)
$RFILES = reportDayFiles( $DTS );
$CH = array();
if( count( $RFILES ) ){
$HOURS = array_diff( array_keys( $RFILES ), array( REPORT_LEGACY_SLOT ) );
$SLOT = count( $HOURS ) ? max( $HOURS ) : REPORT_LEGACY_SLOT;
$ZIZI = new SQLite_DB( $RFILES[$SLOT], SQLITE3_OPEN_READWRITE );
$RLLID = reportRawId( $LLID );
if( reportSlotOf( $LLID ) != $SLOT ){
$RLLID = 0; // new file (next hour / day): everything in it is new
} else {
$MX = $ZIZI->Query( "SELECT MAX(`id`) AS `m` FROM `events`" );
if( count( $MX ) && intval( $MX[0]['m'] ) < $RLLID ) $RLLID = 0; // same hour of another day
};
$QS = "SELECT `id` FROM `events` WHERE `id` > {$RLLID} LIMIT 1";
$CH = $ZIZI->Query( $QS );
};
if( count( $CH ) ){
$QS = "SELECT * FROM nodes";
$result = $DATABASE->Query( $QS, false );
$NodeNames = array();
foreach( $result as $R ) $NodeNames[$R['id']] = $R['name'];
$QS = "SELECT `id`,`node_id`, `evt_type`, `ts`, `ts_ms`, `range_digital`, `azimuth`, `elevation`, `range`, `area`, `lrf_id` FROM `events` WHERE `id` > {$LLID} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 32";
$QS = "SELECT `id`,`node_id`, `evt_type`, `ts`, `ts_ms`, `range_digital`, `azimuth`, `elevation`, `range`, `area`, `lrf_id` FROM `events` WHERE `id` > {$RLLID} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 32";
$LREC = $ZIZI->Query( $QS );
foreach( $LREC as $REC ){
$CR['id'] = intval( $REC['id'] );
$CR['id'] = reportEncodeId( $SLOT, $REC['id'] );
$CR['node_id'] = intval( $REC['node_id'] );
$CR['node_name'] = $NodeNames[$CR['node_id']];
$CR['ts'] = intval( $REC['ts'] );

14
lib/controller/getVideoInfo.php

@ -6,14 +6,20 @@
if( $EID ){
$DS = date("Y/m/d", $DTS );
//$QS = "SELECT * FROM `videos` WHERE `id` = {$VID}";
$QS = "SELECT `videos`.`id`, `videos`.`fps`,`videos`.`uts` as `ts`, `videos`.`md5`, `videos`.`ext`, `videos`.`media_stream_id`, `events_2_videos`.`frame` FROM `events_2_videos` LEFT JOIN `videos` ON( `videos`.`id` = `events_2_videos`.`video_id` ) WHERE `events_2_videos`.`evt_id`={$EID}";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
$LREC = $ZIZI->Query( $QS );
// ID is a global event id (see report_files.php); video ids are returned as global ids of the same file
$SLOT = reportSlotOf( $EID );
$REID = reportRawId( $EID );
$QS = "SELECT `videos`.`id`, `videos`.`fps`,`videos`.`uts` as `ts`, `videos`.`md5`, `videos`.`ext`, `videos`.`media_stream_id`, `events_2_videos`.`frame` FROM `events_2_videos` LEFT JOIN `videos` ON( `videos`.`id` = `events_2_videos`.`video_id` ) WHERE `events_2_videos`.`evt_id`={$REID}";
$ZIZI = reportOpenSlot( $DS, $SLOT );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
if( count( $LREC ) ){
$Pack = array();
$Pack['ts'] = $DTS;
$Pack['videos'] = array();
foreach( $LREC as $Data ) $Pack['videos'][] = $Data;
foreach( $LREC as $Data ){
$Data['id'] = reportEncodeId( $SLOT, $Data['id'] );
$Pack['videos'][] = $Data;
};
echo json_encode( $Pack );
exit();
};

8
lib/controller/setPermanentBubbles.php

@ -76,9 +76,11 @@
};
if( $UID > 1 && $DTS ){
$DS = date("Y/m/d", $DTS );
$QS = "SELECT * FROM `events` WHERE ( `evt_type`=13 OR `evt_type`=14 ) AND `id`>={$BID} AND `id`<={$EID} ORDER BY `ts` ASC, `ts_ms` ASC";
$ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/'.$DS.'/report.db');
$LREC = $ZIZI->Query( $QS );
// BID/EID are global ids of one report file (see report_files.php)
list( $SLOT, $RBID, $REID ) = reportResolveRange( $BID, $EID );
$QS = "SELECT * FROM `events` WHERE ( `evt_type`=13 OR `evt_type`=14 ) AND `id`>={$RBID} AND `id`<={$REID} ORDER BY `ts` ASC, `ts_ms` ASC";
$ZIZI = reportOpenSlot( $DS, $SLOT );
$LREC = $ZIZI ? $ZIZI->Query( $QS ) : array();
if( count( $LREC ) ){
foreach( $LREC as $REC ){
$bid = serchInBubbles( $REC );

74
lib/php/db/report_files.php

@ -0,0 +1,74 @@
<?php
/*
* Report database files of a day folder.
*
* la_mojo writes one report database per local hour into the day folder:
* data/reports/YYYY/MM/DD/report_HH.db (HH = 00..23)
* Days recorded before that change have a single data/reports/YYYY/MM/DD/report.db
* (the "legacy" file); a day during the upgrade can have both.
*
* Row ids (events, pictures, videos) are AUTOINCREMENT per file, so ids sent to the browser
* carry the file ("slot") they belong to:
* global id = slot * REPORT_ID_SLOT + rowid slot: 0..23 = hour file, 24 = legacy report.db
* The browser treats ids as opaque values and sends them back unchanged; controllers decode them
* with reportSlotOf() / reportRawId(). The largest id (24 * 10^7 + 9999999) fits a 32-bit int.
*/
define('REPORT_ID_SLOT', 10000000);
define('REPORT_LEGACY_SLOT', 24);
define('REPORT_RAW_ID_MAX', REPORT_ID_SLOT - 1);
function reportDayDir( $DS ){
global $SYSPath;
return $SYSPath . '/lib/controller/data/reports/' . $DS;
}
// Path of the report file of a slot (does not check existence)
function reportSlotPath( $DS, $slot ){
if( $slot == REPORT_LEGACY_SLOT ) return reportDayDir( $DS ) . '/report.db';
return reportDayDir( $DS ) . sprintf( '/report_%02d.db', $slot );
}
// Existing report files of a day: array( slot => path ), legacy report.db first, then hours ascending
function reportDayFiles( $DS ){
$RV = array();
$P = reportSlotPath( $DS, REPORT_LEGACY_SLOT );
if( file_exists( $P ) ) $RV[REPORT_LEGACY_SLOT] = $P;
for( $H = 0; $H < 24; $H++ ){
$P = reportSlotPath( $DS, $H );
if( file_exists( $P ) ) $RV[$H] = $P;
};
return $RV;
}
// Opens the report file of a slot; NULL if it does not exist (never creates a file)
function reportOpenSlot( $DS, $slot ){
if( $slot < 0 || $slot > REPORT_LEGACY_SLOT ) return NULL;
$P = reportSlotPath( $DS, $slot );
if( !file_exists( $P ) ) return NULL;
return new SQLite_DB( $P, SQLITE3_OPEN_READWRITE );
}
function reportEncodeId( $slot, $id ){
return intval( $slot ) * REPORT_ID_SLOT + intval( $id );
}
function reportSlotOf( $gid ){
return intdiv( intval( $gid ), REPORT_ID_SLOT );
}
function reportRawId( $gid ){
return intval( $gid ) % REPORT_ID_SLOT;
}
/*
* Resolves a BID..EID range of global ids (always inside one report file) to
* array( slot, raw_bid, raw_eid ). If EID points past the file of BID (e.g. "until the end"),
* the range runs to the end of BID's file.
*/
function reportResolveRange( $BID, $EID ){
$slot = reportSlotOf( $BID > 0 ? $BID : $EID );
$rb = ( reportSlotOf( $BID ) == $slot ) ? reportRawId( $BID ) : 0;
$re = ( reportSlotOf( $EID ) == $slot ) ? reportRawId( $EID ) : REPORT_RAW_ID_MAX;
return array( $slot, $rb, $re );
}
?>
Loading…
Cancel
Save