libs-gsweb/GSWExtensions.framework/GSWStatsPage.m
Manuel Guesdon d8acaba816 2003-03-24 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWRequest.m:
		o fix in -_getFormValuesFromMultipartFormData:
		   add [parser expectNoHeaders] to force body parsing as
			otherwise it fail in some context (navigator/form values)
  	* GSWExtensions.framework/GSWCollapsibleComponentContent.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWExceptionPage.m:
		o logs
		o use RCS_ID
	* GSWExtensions.framework/GSWDictionaryRepetition.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWIFrame.m:
		o clean warnings
		o use RCS_ID
	* GSWExtensions.framework/GSWLongResponsePage.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWMetaRefresh.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWPageRestorationErrorPage.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWRedirect.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWSessionCreationErrorPage.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWSessionRestorationErrorPage.m:
		o use RCS_ID
	* GSWExtensions.framework/GSWStatsPage.m:
		o use RCS_ID
	* GSWExtensionsGSW.framework/GSWLogin.m:
		o use RCS_ID
	* GSWExtensionsGSW.framework/GSWSimpleFormComponent.m:
		o use RCS_ID
	* GSWExtensionsGSW.framework/GSWTabComponent.m:
		o use RCS_ID
	* GSWExtensionsGSW.framework/GSWValidationFailureComponent.m:
		o use RCS_ID
	* GSWeb.framework/GSWApplication.m:
		o change setIVar... by takeValue:forKey:
	* GSWeb.framework/GSWElement.m:
		o logs
	* GSWeb.framework/GSWeb.h:
		o removed NSObject+IVarAccess+PerformSel.h inclusion
	* GSWeb.framework/GSWAssociation.m:
		o removed commented set/getIVar
	* GSWeb.framework/GSWComponent.m:
		o removed commented set/getIVar
	* GSWeb.framework/GSWSession.m:
		o retain/release deleteContextID in -savePageInPermanentCache
			(from St�phane Corth�sy <stephane@sente.ch>)
		o retain/release deleteContextID in -_savePage:forChange
			(from St�phane Corth�sy <stephane@sente.ch>)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@16238 72102866-910b-0410-8b05-ffd578937521
2003-03-24 07:45:52 +00:00

192 lines
5.3 KiB
Objective-C

/** GSWStatsPage.m - <title>GSWeb: Class GSWStatsPage</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Apr 1999
$Revision$
$Date$
<abstract></abstract>
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include "GSWExtWOCompatibility.h"
#include "GSWStatsPage.h"
//===================================================================================
@implementation GSWStatsPage
-(id)submit
{
GSWStatisticsStore* statisticsStore = [[self application] statisticsStore];
if (statisticsStore)
{
//[_statisticsStore validateLogin:password];
[[self session] _allowToViewStatistics];
};
return self;
};
-(id)host
{
return [[NSHost currentHost] name];
}
- (void) awake
{
/*
NSString* tmpKey;
NSString* tmpItem;
NSDictionary* detailsDict;
NSDictionary* pagesDict;
NSDictionary* directActionsDict;
NSDictionary* sessionMemoryDict;
NSDictionary* transactions;
NSDictionary* statsDict;
NSDictionary* memoryDict;
NSArray* sessionStats;
NSMutableDictionary* sessionsDict;
NSNumber* maxPageCount;
NSNumber* maxActionCount;
NSDate* maxSessionsDate;
NSString* userName;
NSString* password;
*/
NSLog(@"detailsDict");
NSLog([_detailsDict description]);
NSLog(@"pagesDict");
NSLog([_pagesDict description]);
NSLog(@"directActionsDict");
NSLog([_directActionsDict description]);
NSLog(@"sessionMemoryDict");
NSLog([_sessionMemoryDict description]);
NSLog(@"transactions");
/*NSLog(_transactions);
NSLog(@"statsDict");
NSLog(_statsDict);
NSLog(@"memoryDict");
NSLog(_memoryDict);
NSLog(@"sessionStats");
NSLog(_sessionStats);
NSLog(@"sessionsDict");
NSLog(_sessionsDict);
*/
}
-(id)instance
{
id instance=nil;
NSArray* commandLineArguments = [[NSProcessInfo processInfo] arguments];
unsigned int i=0;
i = [commandLineArguments indexOfObject:@"-n"];
if (i!=NSNotFound && ([commandLineArguments count] > i + 1))
instance=[commandLineArguments objectAtIndex:i+1];
return instance;
};
-(NSNumber*)_maxServedForDictionary:(NSDictionary*)aDictionary
{
int maxServedCount = 0;
int tmpCount=0;
NSDictionary* page = nil;
NSEnumerator* anEnum = [aDictionary objectEnumerator];
while ((page = [anEnum nextObject]))
{
tmpCount = [[page objectForKey:@"Served"] intValue];
maxServedCount = max(maxServedCount,tmpCount);
};
return [NSNumber numberWithInt:maxServedCount];
};
-(id)_initIvars
{
id currentCount=nil;
_statsDict = [[self application] statistics];
_pagesDict = [_statsDict objectForKey:@"Pages"];
_directActionsDict = [_statsDict objectForKey:@"DirectActions"];
_detailsDict = [_statsDict objectForKey:@"Details"];
_transactions = [_statsDict objectForKey:@"Transactions"];
_memoryDict = [_statsDict objectForKey:@"Memory"];
_sessionsDict = [[[NSMutableDictionary alloc] initWithDictionary:
[_statsDict objectForKey:@"Sessions"]]
autorelease];
_sessionMemoryDict = [_sessionsDict objectForKey:@"Avg. Memory Per Session"];
[_sessionsDict removeObjectForKey:@"Avg. Memory Per Session"];
_sessionStats = [_sessionsDict objectForKey:@"Last Session's Statistics"];
[_sessionsDict removeObjectForKey:@"Last Session's Statistics"];
_maxSessionsDate = [_sessionsDict objectForKey:@"Peak Active Sessions Date"];
[_sessionsDict removeObjectForKey:@"Peak Active Sessions Date"];
_maxPageCount = 0;
_maxActionCount = 0;
_maxPageCount = [self _maxServedForDictionary:_pagesDict];
_maxActionCount = [self _maxServedForDictionary:_directActionsDict];
return nil; //??? //TODO
};
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
// ** This should probably be somewhere else.
[self _initIvars];
[super appendToResponse:aResponse
inContext:aContext];
};
-(void)setDetailPercent:(NSNumber*)aValue
{
}
-(NSNumber*)detailPercent
{
int detailPercent=0;
id aTransactionsCount = [_transactions objectForKey:@"Transactions"];
int aDetailCount = [[self detailCount] intValue];
if (aTransactionsCount > 0)
detailPercent=(aDetailCount / [aTransactionsCount intValue]) * 100;
return [NSNumber numberWithInt:detailPercent];
};
-(id)runningTime
{
NSTimeInterval aRunningTime = (-1.0 * [[_statsDict objectForKey:@"StartedAt"] timeIntervalSinceNow]);
NSString* aRunningTimeString = [GSWStatisticsStore timeIntervalDescription:aRunningTime];
return aRunningTimeString;
}
-(id)detailCount
{
return [_detailsDict objectForKey:_tmpKey];
}
@end