Hi,
How can I export all the tasks from all the projects into a CSV (as opposed to going into each project separately)
TIA!
Are you looking for a response that involves code or not?
If so, I wont do it for you, but can at least point you in the right direction, or at least A direction.
Here is your magic:
Now, with some understanding of kanboards code, its fairly simple to make it do what you want.
If you also take a look at metamagik, you’ll see how to utilize your own custom export, and integrate into plugin format.
For non code, use something like phpmyadmin.
Thanks for your quick and detailed response!
Can you expand a bit on the non code options?
Stumbled across the command line interface (cli) in the installation guide.
There is a command like
./cli export:subtasks <project_id> <start_date> <end_date>
e.g.
./cli export:tasks 1 2014-10-01 2014-11-30 >/tmp/my_custom_export.csv would export for table No 1.
Now with a shell script which traverses all project numbers you may get what you want.
Did not try if it works, though, and it is nothing a normal user can do.
With phpmyadmin or phpliteadmin, depending on which DB type you are using, you can just run sql queries to get what you want, out of the database, and then export.
Thanks but that won’t work. It will generate a different csv for each project and I need them all in one file.
Thanks! will try that
If you use in your shellscript “>>” instead of “>” it will append to the file instead of overwrite.
Honestly, the code is the simplest of all solutions. Probably, 3 lines.
Get all the project ids, and iterate through them all…
Might seem scary to you, i don’t know, but it really shouldn’t be.
public function export($from, $to) <---remove $project_id here
{
$projects = $this->projectModel->getAllIds(); <---get all the project ids here
$results = array($this->getColumns()); <--need to move this out of the iteration
foreach ($projects as $project_id) { <--- start the iteration here
$tasks = $this->getTasks($project_id, $from, $to);
$taskIds = array_column($tasks, 'id');
$tags = $this->taskTagModel->getTagsByTaskIds($taskIds);
$colors = $this->colorModel->getList();
foreach ($tasks as &$task) {
$task = $this->format($task, $colors, $tags);
$results[] = array_values($task);
}
} <---end iteration here
return $results;
}
should work, been a long time since i have looked at the code, but 99% sure its that simple. and yeah, so that’s 3 lines, and 1 small edit to another line, while moving another line outside the iteration…if you want, you could just edit that code directly, which would be a hack (and you would have to undo it, if you ever want the original version export function to work again), but would get you what you want, or you could litterlly go the extra mile and create a link somewhere in a template to add this export and make a little plugin. MetaMagik would be your guide on how to utilize your own Export, which I could explain if you want, it would also be very minimal effort of code, and the only difference would be that you need to add the export option instead of overriding the current one.
@creecros you’ve just coded more than a code snippet for a plug-in that would mean to do that! Congrats!
Hey, I’m trying to implement this and I didn’t get the expected result… can anyone help me?
3 years later, someone tested it out…lol
So what was your result?
It’s still practically the same code, but since I’m using metamagik, I tried to fit in as follows:
But the file wasn’t even generated
Tested with MetaMagik on KB v1.2.27, works just fine.
public function export($project_id, $from, $to)
{
$projects = $this->projectModel->getAllIds();
$results = array($this->getColumns($project_id));
foreach ($projects as $project_id) {
$tasks = $this->getTasks($project_id, $from, $to);
$taskIds = array_column($tasks, 'id');
$tags = $this->taskTagModel->getTagsByTaskIds($taskIds);
$colors = $this->colorModel->getList();
$metafields = $this->metadataTypeModel->getAllInScope($project_id);
$fieldtest = array();
foreach ($metafields as $fields) { array_push($fieldtest, $fields['human_name']); }
foreach ($tasks as $task) {
$metadata = $this->findMissingFields($task['id'], $project_id);
$metaval = array();
foreach ($metadata as $key => $value) {
if (in_array($key, $fieldtest)) {
array_push($metaval, $value);
}
}
$task = $this->format($task, $colors, $tags, $metaval);
$results[] = array_values($task);
}
}
return $results;
}
I would guess you have a bad DATE RANGE if the file is not even generated.
Oh, I can see you ended your foreach
loop in the wrong place. Needs to end right before the return, as I noted in my previous post 3 years ago
Thank you very much for your help! A suggestion to you is to put an option with a button in the metamagik in the future, again thank you