roadmap fixes

This commit is contained in:
Jeremy Kauffman 2017-06-21 16:53:53 -04:00
parent a441f0aa16
commit 6d7440a891
4 changed files with 52 additions and 30 deletions

View file

@ -220,9 +220,9 @@ class ContentActions extends Actions
{ {
$lastItem = end($items); $lastItem = end($items);
$project = $lastItem['project']; $project = $lastItem['project'];
if (!isset($projectMaxVersions[$project]) || strnatcasecmp($lastItem['version'], $projectMaxVersions[$project]) > 0) if (!isset($projectMaxVersions[$project]) || $lastItem['sort_key'] > $projectMaxVersions[$project])
{ {
$projectMaxVersions[$project] = $lastItem['version']; $projectMaxVersions[$project] = $lastItem['sort_key'];
} }
} }
} }

View file

@ -19,7 +19,7 @@ class Asana
$tasks = []; $tasks = [];
$tags = [ $tags = [
192699565737944 => 'Ongoing', 192699565737944 => 'Open Beta',
192699565737946 => 'Upcoming', 192699565737946 => 'Upcoming',
192699565737948 => 'Future' 192699565737948 => 'Future'
]; ];
@ -40,12 +40,14 @@ class Asana
else else
{ {
$projectName = 'Other'; $projectName = 'Other';
$projectId = null;
} }
$tasks[$tagLabel][] = array_intersect_key($fullTask, ['name' => null]) + [ $tasks[$tagLabel][] = array_intersect_key($fullTask, ['name' => null]) + [
'badge' => $projectName, 'badge' => $projectName,
'date' => $fullTask['due_on'] ?? null, 'date' => $fullTask['due_on'] ?? null,
'body' => nl2br($fullTask['notes']) , 'body' => nl2br($fullTask['notes']),
'group' => $tagLabel, 'group' => $tagLabel,
'project_id' => $projectId,
'assignee' => $fullTask['assignee'] ? ucwords($fullTask['assignee']['name']) : '' 'assignee' => $fullTask['assignee'] ? ucwords($fullTask['assignee']['name']) : ''
]; ];
} }
@ -64,6 +66,10 @@ class Asana
{ {
return $tA['date'] ? -1 : 1; return $tA['date'] ? -1 : 1;
} }
if ($tA['project_id'] xor $tB['project_id'])
{
return $tA['project_id'] ? -1 : 1;
}
return $tA['date'] < $tB['date'] ? -1 : 1; return $tA['date'] < $tB['date'] ? -1 : 1;
}); });
} }

View file

@ -106,21 +106,24 @@ class Github
$sets = []; $sets = [];
$allReleases = []; $allReleases = [];
$project = 'lbry'; $projects = ['lbry' => 'Daemon', 'lbry-app' => 'App'];
$page = 1;
do foreach($projects as $project => $projectLabel)
{ {
$releases = static::get('/repos/lbryio/' . $project . '/releases?page=' . $page, $cache); $page = 1;
$page++; do
$allReleases = array_merge($allReleases, array_map(function ($release) use ($project)
{ {
return $release + ['project' => $project]; $releases = static::get('/repos/lbryio/' . $project . '/releases?page=' . $page, $cache);
}, array_filter($releases, function ($release) $page++;
{ $allReleases = array_merge($allReleases, array_map(function ($release) use ($project, $projectLabel)
return ($release['tag_name'] ?? null) && ($release['published_at'] ?? null) && !$release['prerelease']; {
}))); return $release + ['project' => $projectLabel];
} while (count($releases) >= 30); }, array_filter($releases, function ($release)
{
return isset($release['tag_name']) && isset($release['published_at']) && $release['published_at'];
})));
} while (count($releases) >= 30);
}
foreach ($allReleases as $release) foreach ($allReleases as $release)
{ {
@ -128,23 +131,36 @@ class Github
$matches = null; $matches = null;
if (preg_match('/^v(\d+)\.(\d+)\./', $release['tag_name'] ?? '', $matches)) if (preg_match('/^v(\d+)\.(\d+)\./', $release['tag_name'] ?? '', $matches))
{ {
$group = 'v' . $matches[1] . '.' . $matches[2]; $group = $release['project'] . ' v' . $matches[1] . '.' . $matches[2];
} }
if ($group) if ($group)
{ {
$sets[$group][] = [ $sets[$group][] = array_intersect_key($release, [
'project' => $release['project'], 'prerelease' => null, 'tag_name' => null, 'published_at' => null, 'project' => null
'date' => date('Y-m-d', strtotime($release['created_at'])), ]) + [
'created_at' => $release['created_at'], 'date' => date('Y-m-d', strtotime($release['created_at'])),
'name' => $release['name'] ?: $release['tag_name'], //I thought published_at, but GitHub displays created_at and published_at is out of sync sometimes (0.3.2, 0.3.3)
'url' => $release['html_url'], 'name' => $release['name'] ?: $release['tag_name'],
'version' => $release['tag_name'], 'url' => $release['html_url'],
'body' => ParsedownExtra::instance()->text($release['body']) 'major_version' => (int)$matches[1],
]; 'minor_version' => (int)$matches[2],
'patch_version' => (int)isset($matches[3]) ? $matches[3] : 0,
'sort_key' => (int)$matches[1] * 1000000 + (int)$matches[2] * 1000 + (int)($matches[3] ?? 0),
'version' => $matches[1] . '.' . $matches[2] . '.' . (isset($matches[3]) ? $matches[3] : ''),
'body' => ParsedownExtra::instance()->text($release['body'])
];
} }
} }
uasort($sets, function ($sA, $sB) { return $sA[0]['created_at'] <=> $sB[0]['created_at']; }); uasort($sets, function ($sA, $sB)
{
if ($sA[0]['project'] != $sB[0]['project'])
{
return $sA[0]['project'] < $sB[0]['project'] ? -1 : 1;
}
return $sA[0]['sort_key'] < $sB[0]['sort_key'] ? -1 : 1;
});
foreach ($sets as $group => &$groupSet) foreach ($sets as $group => &$groupSet)
{ {
usort($groupSet, function ($rA, $rB) { return $rA['created_at'] <=> $rB['created_at']; }); usort($groupSet, function ($rA, $rB) { return $rA['created_at'] <=> $rB['created_at']; });

View file

@ -29,15 +29,15 @@
<div class="text-center"><a href="javascript:;" class="link-primary show-all-roadmap-groups">Show Earlier Releases</a></div> <div class="text-center"><a href="javascript:;" class="link-primary show-all-roadmap-groups">Show Earlier Releases</a></div>
<?php foreach($items as $group => $groupItems): ?> <?php foreach($items as $group => $groupItems): ?>
<?php $lastItem = end($groupItems) ?> <?php $lastItem = end($groupItems) ?>
<?php $isOpen = !isset($lastItem['project']) || !isset($lastItem['version']) || $lastItem['version'] === $projectMaxVersions[$lastItem['project']] ?> <?php $isOpen = !isset($lastItem['project']) || !isset($lastItem['sort_key']) || $lastItem['sort_key'] === $projectMaxVersions[$lastItem['project']] ?>
<h2 class="roadmap-group-title" <?php echo !$isOpen ? 'style="display: none"' : '' ?>"> <h2 class="roadmap-group-title" <?php echo !$isOpen ? 'style="display: none"' : '' ?>">
<span class="roadmap-group-title-label"> <span class="roadmap-group-title-label">
<?php echo $group ?> <?php echo isset($lastItem['version']) && $lastItem['version'] === $projectMaxVersions[$lastItem['project']] ? '(latest)' : '' ?> <?php echo $group ?> <?php echo isset($lastItem['sort_key']) && $lastItem['sort_key'] === $projectMaxVersions[$lastItem['project']] ? '(latest)' : '' ?>
</span> </span>
</h2> </h2>
<div class="roadmap-group <?php echo !$isOpen ? 'roadmap-group-closed' : '' ?>"> <div class="roadmap-group <?php echo !$isOpen ? 'roadmap-group-closed' : '' ?>">
<?php $lastItem = end($groupItems) ?> <?php $lastItem = end($groupItems) ?>
<?php $maxItems = isset($lastItem['version']) ? 1 : count($groupItems) ?> <?php $maxItems = isset($lastItem['sort_key']) ? 1 : count($groupItems) ?>
<?php $index = 0 ?> <?php $index = 0 ?>
<?php if (count($groupItems) > $maxItems): ?> <?php if (count($groupItems) > $maxItems): ?>
<div class="text-center spacer1"><a href="javascript:;" class="link-primary show-all-roadmap-group-items">Show All Items for <?php echo $group ?></a></div> <div class="text-center spacer1"><a href="javascript:;" class="link-primary show-all-roadmap-group-items">Show All Items for <?php echo $group ?></a></div>