Commit 301a6ff9 authored by beardedwarrior's avatar beardedwarrior

changes to reflect new direction

jekyll site now uses json, formatted the proposals to reflect that
added additional fields to db to save data required for the site,
pulling merge proposals in via git submodule for processing data variables
parent 18d446f9
[submodule "storage/app/ffs-proposals"]
path = storage/app/ffs-proposals
url = https://repo.getmonero.org/monero-project/ffs-proposals.git
...@@ -6,7 +6,6 @@ use App\Project; ...@@ -6,7 +6,6 @@ use App\Project;
use GitLab\Connection; use GitLab\Connection;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class fetchMergeRequests extends Command class fetchMergeRequests extends Command
{ {
...@@ -36,8 +35,6 @@ class fetchMergeRequests extends Command ...@@ -36,8 +35,6 @@ class fetchMergeRequests extends Command
/** /**
* Execute the console command. * Execute the console command.
*
* @return mixed
*/ */
public function handle() public function handle()
{ {
...@@ -45,44 +42,17 @@ class fetchMergeRequests extends Command ...@@ -45,44 +42,17 @@ class fetchMergeRequests extends Command
$projects = $connection->mergeRequests('all'); $projects = $connection->mergeRequests('all');
foreach ($projects as $project) { foreach ($projects as $project) {
$title = str_replace('[IDEA]','',$project->title);
// create requests that are still pending // create requests that are still pending
$project = Project::firstOrNew([ $project = Project::firstOrNew([
'merge_request_id' => $project->id 'merge_request_id' => $project->id,
],[ ],[
'title' => $project->title, 'title' => $title,
'state' => $project->state 'gitlab_state' => $project->state,
'gitlab_username' => $project->author->username,
'gitlab_url' => $project->web_url,
]); ]);
// check if there is a payment_id and an address
// check if the amount field has been supplied
$project->save(); $project->save();
} }
// id, title, state, username,
// save merge requests
// compare to current merge requests
// if merge request is missing is it closed or merged
return;
}
/**
* Gets the ffs amount requested from a file
*
* @param string $filename
* @return int
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getAmountFromText($filename = 'test-ffs.md')
{
$input = Storage::get($filename);
$lines = preg_split('/\r\n|\r|\n/', $input);
foreach($lines as $line) {
$line = str_replace(' ','', $line);
$details = explode(':', $line);
if ($details[0] === 'amount') {
return $details[1];
}
}
return 0;
} }
} }
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class ProcessProposals extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'proposal:process';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check for changes to proposals';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
public function handle()
{
$amounts = [];
$files = Storage::files('ffs-proposals');
foreach ($files as $file) {
if (strpos($file,'.md')) {
$amount['name'] = $file;
$amount['amount'] = $this->getAmountFromText($file);
$amounts[] = $amount;
}
}
dd($amounts);
}
/**
* Gets the ffs amount requested from a file
*
* @param string $filename
* @return int
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getAmountFromText($filename = 'additional-gui-dev.md')
{
$input = Storage::get($filename);
$lines = preg_split('/\r\n|\r|\n/', $input);
foreach($lines as $line) {
$line = str_replace(' ','', $line);
$details = explode(':', $line);
if ($details[0] === 'amount') {
return $details[1];
}
}
return 0;
}
}
<?php
namespace App\Console\Commands;
use App\Project;
use Illuminate\Console\Command;
use stdClass;
use Symfony\Component\Yaml\Yaml;
class UpdateSiteProposals extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ffs:update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update the files required for jeykll site';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
public function handle()
{
$ffs = json_decode(\Storage::get('_data_ffs.json'));
$ffs[0]->proposals = array_merge($ffs[0]->proposals, $this->getNewProposals());
$yaml = json_encode($ffs, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
\Storage::put('new.json', $yaml);
}
public function getNewProposals()
{
$responseProposals = [];
$proposals = Project::where('gitlab_state', 'opened')->get();
foreach ($proposals as $proposal) {
$prop = new stdClass();
$prop->name = $proposal->title;
$prop->{'gitlab-url'} = $proposal->gitlab_url;
$prop->author = $proposal->gitlab_username;
$prop->date = $proposal->gitlab_created_at->format('F j, Y');
$responseProposals[] = $prop;
}
return $responseProposals;
}
}
...@@ -37,6 +37,8 @@ use SimpleSoftwareIO\QrCode\Facades\QrCode; ...@@ -37,6 +37,8 @@ use SimpleSoftwareIO\QrCode\Facades\QrCode;
class Project extends Model class Project extends Model
{ {
protected $guarded = ['id']; protected $guarded = ['id'];
protected $dates = ['gitlab_created_at', 'created_at', 'updated_at'];
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
......
...@@ -3,13 +3,18 @@ ...@@ -3,13 +3,18 @@
use Faker\Generator as Faker; use Faker\Generator as Faker;
$factory->define(\App\Project::class, function (Faker $faker) { $factory->define(\App\Project::class, function (Faker $faker) {
$state = $faker->randomElement(['OPENED', 'IDEA', 'FUNDING-REQUIRED', 'WORK-IN-PROGRESS', 'COMPLETED']);
$status = $faker->randomElement(['opened', 'closed', 'locked', 'merged']); $status = $faker->randomElement(['opened', 'closed', 'locked', 'merged']);
return [ return [
'title' => $faker->sentence(), 'title' => $faker->sentence(),
'payment_id' => $faker->sha256, 'payment_id' => $faker->sha256,
'target_amount' => $faker->randomFloat(2, 0, 2000), 'target_amount' => $faker->randomFloat(2, 0, 2000),
'state' => $status, 'state' => $state,
'merge_request_id' => $faker->randomNumber(6), 'merge_request_id' => $faker->randomNumber(6),
'gitlab_username' => $faker->userName,
'gitlab_url' => $faker->url,
'gitlab_state' => $status,
'gitlab_created_at' => $faker->dateTimeThisYear,
'created_at' => $faker->dateTimeThisYear, 'created_at' => $faker->dateTimeThisYear,
'updated_at' => $faker->dateTimeThisYear, 'updated_at' => $faker->dateTimeThisYear,
]; ];
......
...@@ -19,8 +19,12 @@ class CreateProjectsTable extends Migration ...@@ -19,8 +19,12 @@ class CreateProjectsTable extends Migration
$table->string('payment_id')->nullable(); $table->string('payment_id')->nullable();
$table->string('address')->nullable(); $table->string('address')->nullable();
$table->string('target_amount')->nullable(); $table->string('target_amount')->nullable();
$table->string('state')->default('opened'); $table->string('state')->default('OPENED');
$table->unsignedInteger('merge_request_id')->unique(); $table->unsignedInteger('merge_request_id')->unique();
$table->string('gitlab_username');
$table->string('gitlab_url');
$table->string('gitlab_state')->default('opened');
$table->timestamp('gitlab_created_at');
$table->timestamps(); $table->timestamps();
}); });
} }
......
Subproject commit 4459b497ee672bcc7e0848f2da7eed93152e4e06
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