Skip to content

Instantly share code, notes, and snippets.

@lasar
Created July 30, 2013 15:30
Show Gist options
  • Save lasar/6114019 to your computer and use it in GitHub Desktop.
Save lasar/6114019 to your computer and use it in GitHub Desktop.
function saveData($name, $data) {
file_put_contents('export/'.$name.'.json', json_encode($data));
}
$users = $fg->action('user/getRelated');
saveData('users', $users['users']);
$projects = $fg->action('projects/get', array('format'=>'flat'));
saveData('projects', $projects['projects']);
$projectsTree = $fg->action('projects/get', array('format'=>'tree'));
saveData('projectsTree', $projectsTree['projects']);
$tickets = $fg->action('tickets/get', array(
'status' => array(0,1,2,3,4,5),
));
// print_r($tickets);
print count($users['users'])." users\n";
print count($projects['projects'])." projects\n";
print count($tickets['tickets'])." tickets\n";
$start = microtime(true);
$c = 0;
foreach($tickets['tickets'] as $ticket) {
$notes = $fg->action('notes/get', array(
'ticket_id' => $ticket['id']
));
print "$c #".$ticket['id']." ".(microtime(true)-$start)."\n";
$data = array(
'ticket' => $ticket,
'notes' => $notes['notes'],
'project' => $projects['projects'][$ticket['project_id']],
'user' => $users['users'][$ticket['user_id']],
'assigned' => $users['users'][$ticket['assigned_id']],
);
saveData('tickets/'.$ticket['id'], $data);
$c++;
}
print "\n";
$end = microtime(true);
print "Total time: ".($end-$start)."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment