Sample Data

[article] [edit page] [discussion] [history]

From Humanitarian-FOSS Project Development Site

This page contains information about the Summer 2008 Humanitarian FOSS Project Summer Institute.

Week Three: Sample Data


Abstract: Sample Data is exercise that Team Sahana tackled during week three of the HFOSS Program. The module created this week randomly creates sample data for a person that is then stored into the database. The data that was randomly generated is then used for the Sahana Disaster Management website. For example, random names were generated from data, containing 88,000 last names downloaded from census 1990.

function get_random_person(){

	$data = array();
	$rID = rand(0, 88799);
	$res = mysql_query("SELECT lname FROM lastnames where id = $rID LIMIT 1");
	$res = mysql_fetch_array($res);
	$data['lname'] = ucfirst(strtolower($res[0]));

	$rID = rand(0,1)?rand(0,4273):rand(4273, 5494);
	$res = mysql_query("SELECT fname, gender FROM firstnames WHERE id = $rID LIMIT 1");
	$res = mysql_fetch_array($res);
	$data['fname'] = ucfirst(strtolower($res[0]));
	$data['gender'] = strtoupper($res[1]);
	$data['p_uuid'] = 'test'.shn_generate_uuid(36);

	$data['birth_date'] = get_random_birthdate();
	$dates = get_random_dates($data['birth_date']);
	$data['date_avail_start'] = $dates[0];
	$data['date_avail_end'] = $dates[1];
	$data['hrs_avail_start'] = $dates[2];
	$data['hrs_avail_end'] = $dates[3];

	return $data;

The code created to generate a person in terms of a first name, last name, and birth date follows:

function get_random_birthdate(){
	$minDate = "January 2, 1930";
	$maxDate = time()-60*60*24*365*18;
	$randomTimeStamp = rand(strtotime($minDate), $maxDate);
	$randomBD= date("Y-m-d",$randomTimeStamp);
	return $randomBD;

function get_random_dates($birthdate){
	$minDate = time()-62*24*60*60;
	$maxDate = time()+60*60*24*62;
	$randomTimeStamp = rand($minDate, $maxDate);
	$randomStart= date("Y-m-d",$randomTimeStamp);	
	$randomTimeStart= date("g-A",$randomTimeStamp);
	$randomTimeStamp = rand($randomTimeStamp,$maxDate);
	$randomEnd = date("Y-m-d",$randomTimeStamp);
	$randomTimeEnd = date("g-A",$randomTimeStamp);

	$randomDates = array();

	echo"START TIME: ",$randomDates[2]=$randomTimeStart;
	echo" END TIME: ",$randomDates[3]=$randomTimeEnd;
	echo  $birthdate;
	return $randomDates;

This week with data sampling we created six sample projects each containing 5 fictional positions(*each position can be occupied by a large number of people in order to assign more people to a project). The positions were populated with the sample data to test the execution process of Sahana. There were over 50 thousand sample volunteers added, and stored in the database.

Image: Project_Snapshot.jpg

Developers: Antonio (Team Leader), Dimitar, James, Eli.
Mentors: Frank Federich, Trishan de Lanerolle , Ralph Morelli

  • The deliverable for this project will be a deployable application with source code available on sourceforge.
Personal tools