Commit f6c64cba authored by xiphon's avatar xiphon

implemented milestones support

parent 8e8323cb
......@@ -85,6 +85,7 @@ class ProcessProposals extends Command
$author = htmlspecialchars($detail['values']['author'], ENT_QUOTES);
$date = strtotime($detail['values']['date']);
$state = $this::layoutToState[$detail['values']['layout']];
$milestones = $detail['values']['milestones'];
$title = htmlspecialchars($detail['values']['title'], ENT_QUOTES);
$project = Project::where('filename', $filename)->first();
......@@ -112,6 +113,8 @@ class ProcessProposals extends Command
$project->state = $state;
$project->target_amount = $amount;
$project->title = $title;
$project->milestones = sizeof($milestones);
$project->milestones_completed = array_reduce($milestones, function($k, $milestone) { return $milestone['done'] ? $k + 1 : $k; }, 0);
$project->save();
} catch (\Exception $e) {
$this->error("Error processing project $filename: {$e->getMessage()}");
......
......@@ -107,6 +107,7 @@ class UpdateSiteProposals extends Command
$prop->name = $proposal->title;
$prop->{'gitlab-url'} = $proposal->gitlab_url;
$prop->{'local-url'} = '#';
$prop->milestones = $proposal->milestones;
$prop->{'donate-url'} = url("projects/{$proposal->payment_id}/donate");
$prop->percentage = $proposal->percentage_funded;
$prop->amount = $proposal->target_amount;
......@@ -130,9 +131,12 @@ class UpdateSiteProposals extends Command
$prop->name = $proposal->title;
$prop->{'gitlab-url'} = $proposal->gitlab_url;
$prop->{'local-url'} = '#';
$prop->milestones = 0;
$prop->{'milestones-completed'} = 0;
$prop->{'milestones-percentage'} = 0;
$prop->milestones = $proposal->milestones;
$prop->{'milestones-completed'} = $proposal->milestones_completed;
$milestones_percentage = min(100, (int)(($proposal->milestones_completed * 100) / $proposal->milestones));
$prop->{'milestones-percentage'} = $milestones_percentage;
$prop->percentage = $proposal->percentage_funded;
$prop->amount = $proposal->target_amount;
$prop->{'amount-funded'} = $proposal->amount_received;
......
......@@ -25,6 +25,8 @@ class CreateProjectsTable extends Migration
$table->float('raised_amount')->default(0);
$table->string('state');
$table->string('filename')->unique();
$table->unsignedInteger('milestones');
$table->unsignedInteger('milestones_completed')->default(0);
$table->string('gitlab_url')->nullable();
$table->timestamps();
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment