Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
xiphon
CCS Backend
Commits
ae970f85
Commit
ae970f85
authored
Jan 27, 2019
by
xiphon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
omit proposals formatting code duplication
parent
f6c64cba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
44 deletions
+23
-44
app/Console/Commands/UpdateSiteProposals.php
app/Console/Commands/UpdateSiteProposals.php
+23
-44
No files found.
app/Console/Commands/UpdateSiteProposals.php
View file @
ae970f85
...
...
@@ -42,14 +42,14 @@ class UpdateSiteProposals extends Command
{
$response
=
[
$this
->
ideaProposals
(),
$this
->
f
undingRequired
Proposals
(
),
$this
->
workInProgressProposals
(
),
$this
->
getProposals
(
'F
unding
Required
'
,
'FUNDING-REQUIRED'
),
$this
->
getProposals
(
'Work in Progress'
,
'WORK-IN-PROGRESS'
),
];
$json
=
json_encode
(
$response
,
JSON_UNESCAPED_SLASHES
|
JSON_PRETTY_PRINT
);
\
Storage
::
put
(
'ffs.json'
,
$json
);
}
p
ublic
function
ideaProposals
()
p
rivate
function
ideaProposals
()
{
$group
=
new
stdClass
();
$group
->
stage
=
'Ideas'
;
...
...
@@ -96,56 +96,35 @@ class UpdateSiteProposals extends Command
return
$group
;
}
p
ublic
function
f
undingRequiredProposals
(
)
p
rivate
function
f
ormatProposal
(
$proposal
)
{
$group
=
new
stdClass
();
$group
->
stage
=
'Funding Required'
;
$responseProposals
=
[];
$proposals
=
Project
::
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
->
milestones
=
$proposal
->
milestones
;
$prop
->
{
'donate-url'
}
=
url
(
"projects/
{
$proposal
->
payment_id
}
/donate"
);
$prop
->
percentage
=
$proposal
->
percentage_funded
;
$prop
->
amount
=
$proposal
->
target_amount
;
$prop
->
{
'amount-funded'
}
=
$proposal
->
amount_received
;
$prop
->
author
=
$proposal
->
author
;
$prop
->
date
=
$proposal
->
created_at
->
format
(
'F j, Y'
);
$responseProposals
[]
=
$prop
;
}
$group
->
proposals
=
$responseProposals
;
return
$group
;
$prop
=
new
stdClass
();
$prop
->
name
=
$proposal
->
title
;
$prop
->
{
'donate-url'
}
=
url
(
"projects/
{
$proposal
->
payment_id
}
/donate"
);
$prop
->
{
'gitlab-url'
}
=
$proposal
->
gitlab_url
;
$prop
->
{
'local-url'
}
=
'#'
;
$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
;
$prop
->
author
=
$proposal
->
author
;
$prop
->
date
=
$proposal
->
created_at
->
format
(
'F j, Y'
);
return
$prop
;
}
p
ublic
function
workInProgressProposals
(
)
p
rivate
function
getProposals
(
$stage
,
$state
)
{
$group
=
new
stdClass
();
$group
->
stage
=
'Work in Progress'
;
$group
->
stage
=
$stage
;
$responseProposals
=
[];
$proposals
=
Project
::
where
(
'state'
,
'WORK-IN-PROGRESS'
)
->
get
();
$proposals
=
Project
::
where
(
'state'
,
$state
)
->
get
();
foreach
(
$proposals
as
$proposal
)
{
$prop
=
new
stdClass
();
$prop
->
name
=
$proposal
->
title
;
$prop
->
{
'gitlab-url'
}
=
$proposal
->
gitlab_url
;
$prop
->
{
'local-url'
}
=
'#'
;
$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
;
$prop
->
author
=
$proposal
->
author
;
$prop
->
date
=
$proposal
->
created_at
->
format
(
'F j, Y'
);
$responseProposals
[]
=
$prop
;
$responseProposals
[]
=
$this
->
formatProposal
(
$proposal
);
}
$group
->
proposals
=
$responseProposals
;
return
$group
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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