Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
beardedwarrior
ffs
Commits
a73ad50c
Commit
a73ad50c
authored
Dec 23, 2018
by
beardedwarrior
Browse files
added better processing of the proposal files
parent
301a6ff9
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/Console/Commands/ProcessProposals.php
View file @
a73ad50c
...
...
@@ -41,7 +41,7 @@ class ProcessProposals extends Command
foreach
(
$files
as
$file
)
{
if
(
strpos
(
$file
,
'.md'
))
{
$amount
[
'name'
]
=
$file
;
$amount
[
'
amount
'
]
=
$this
->
getAmountFromText
(
$file
);
$amount
[
'
values
'
]
=
$this
->
getAmountFromText
(
$file
);
$amounts
[]
=
$amount
;
}
}
...
...
@@ -52,20 +52,40 @@ class ProcessProposals extends Command
* Gets the ffs amount requested from a file
*
* @param string $filename
* @return
int
* @return
array
* @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
);
$values
=
[];
$flag
=
false
;
$isPayoutLine
=
false
;
foreach
(
$lines
as
$line
)
{
$line
=
str_replace
(
' '
,
''
,
$line
);
if
(
$line
===
'---'
)
{
if
(
$flag
===
true
)
{
break
;
}
$flag
=
true
;
continue
;
}
$details
=
explode
(
':'
,
$line
);
if
(
$details
[
0
]
===
'amount'
)
{
return
$details
[
1
];
if
(
count
(
$details
)
<
2
)
{
continue
;
}
if
(
$details
[
0
]
===
'payouts'
)
{
$isPayoutLine
=
true
;
continue
;
}
if
(
$isPayoutLine
)
{
$name
=
trim
(
str_replace
(
'-'
,
''
,
$details
[
0
]));
$values
[
'payouts'
][][
$name
]
=
ltrim
(
$details
[
1
]);
continue
;
}
$values
[
$details
[
0
]]
=
ltrim
(
$details
[
1
]);
}
return
0
;
return
$values
;
}
}
app/Console/Commands/UpdateSiteProposals.php
View file @
a73ad50c
...
...
@@ -38,16 +38,21 @@ class UpdateSiteProposals extends 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
);
$response
=
[
$this
->
ideaProposals
(),
$this
->
fundingRequiredProposals
(),
$this
->
workInProgressProposals
(),
];
$json
=
json_encode
(
$response
,
JSON_UNESCAPED_SLASHES
|
JSON_PRETTY_PRINT
);
\
Storage
::
put
(
'new.json'
,
$json
);
}
public
function
getNew
Proposals
()
public
function
idea
Proposals
()
{
$group
=
new
stdClass
();
$group
->
stage
=
'Ideas'
;
$responseProposals
=
[];
$proposals
=
Project
::
where
(
'gitlab_state'
,
'opened'
)
->
get
();
$proposals
=
Project
::
where
(
'gitlab_state'
,
'opened'
)
->
where
(
'state'
,
'IDEA'
)
->
get
();
foreach
(
$proposals
as
$proposal
)
{
$prop
=
new
stdClass
();
$prop
->
name
=
$proposal
->
title
;
...
...
@@ -56,6 +61,56 @@ class UpdateSiteProposals extends Command
$prop
->
date
=
$proposal
->
gitlab_created_at
->
format
(
'F j, Y'
);
$responseProposals
[]
=
$prop
;
}
return
$responseProposals
;
$group
->
proposals
=
$responseProposals
;
return
$group
;
}
public
function
fundingRequiredProposals
()
{
$group
=
new
stdClass
();
$group
->
stage
=
'Funding Required'
;
$responseProposals
=
[];
$proposals
=
Project
::
where
(
'gitlab_state'
,
'merged'
)
->
where
(
'state'
,
'FUNDING-REQUIRED'
)
->
get
();
foreach
(
$proposals
as
$proposal
)
{
$prop
=
new
stdClass
();
$prop
->
name
=
$proposal
->
title
;
$prop
->
{
'gitlab-url'
}
=
$proposal
->
gitlab_url
;
$prop
->
{
'local-url'
}
=
'#'
;
$prop
->
{
'donate-url'
}
=
'#'
;
$prop
->
percentage
=
0
;
$prop
->
amount
=
$proposal
->
target_amount
;
$prop
->
{
'amount-funded'
}
=
$proposal
->
target_amount
;
$prop
->
author
=
$proposal
->
gitlab_username
;
$prop
->
date
=
$proposal
->
gitlab_created_at
->
format
(
'F j, Y'
);
$responseProposals
[]
=
$prop
;
}
$group
->
proposals
=
$responseProposals
;
return
$group
;
}
public
function
workInProgressProposals
()
{
$group
=
new
stdClass
();
$group
->
stage
=
'Work in Progress'
;
$responseProposals
=
[];
$proposals
=
Project
::
where
(
'gitlab_state'
,
'merged'
)
->
where
(
'state'
,
'WORK-IN-PROGRESS'
)
->
get
();
foreach
(
$proposals
as
$proposal
)
{
$prop
=
new
stdClass
();
$prop
->
name
=
$proposal
->
title
;
$prop
->
{
'gitlab-url'
}
=
$proposal
->
gitlab_url
;
$prop
->
{
'local-url'
}
=
'#'
;
$prop
->
milestones
=
4
;
$prop
->
{
'milestones-completed'
}
=
4
;
$prop
->
{
'milestones-percentage'
}
=
100
;
$prop
->
percentage
=
0
;
$prop
->
amount
=
$proposal
->
target_amount
;
$prop
->
{
'amount-funded'
}
=
$proposal
->
target_amount
;
$prop
->
author
=
$proposal
->
gitlab_username
;
$prop
->
date
=
$proposal
->
gitlab_created_at
->
format
(
'F j, Y'
);
$responseProposals
[]
=
$prop
;
}
$group
->
proposals
=
$responseProposals
;
return
$group
;
}
}
database/migrations/2018_09_10_211623_create_projects_table.php
View file @
a73ad50c
...
...
@@ -20,6 +20,7 @@ class CreateProjectsTable extends Migration
$table
->
string
(
'address'
)
->
nullable
();
$table
->
string
(
'target_amount'
)
->
nullable
();
$table
->
string
(
'state'
)
->
default
(
'OPENED'
);
$table
->
string
(
'filename'
)
->
nullable
();
$table
->
unsignedInteger
(
'merge_request_id'
)
->
unique
();
$table
->
string
(
'gitlab_username'
);
$table
->
string
(
'gitlab_url'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment