From de07665a8b83550aaa607ffa0735edc6cf9d5c86 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 19 Nov 2025 19:00:01 -0600 Subject: [PATCH] Project boards: only show contexts with selected issues. --- pit.nimble | 4 ++-- src/pit/cliconstants.nim | 4 ++-- src/pit/projects.nim | 23 +++++++++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/pit.nimble b/pit.nimble index 0556c1e..e52cf1b 100644 --- a/pit.nimble +++ b/pit.nimble @@ -1,6 +1,6 @@ # Package -version = "4.30.0" +version = "4.30.1" author = "Jonathan Bernard" description = "Personal issue tracker." license = "MIT" @@ -27,4 +27,4 @@ requires @[ ] task updateVersion, "Update the version of this package.": - exec "update_nim_package_version pit 'src/pit/cliconstants.nim'" + exec "update_nim_package_version pit 'src/pit/cliconstants.nim'" \ No newline at end of file diff --git a/src/pit/cliconstants.nim b/src/pit/cliconstants.nim index 852910d..010d8bf 100644 --- a/src/pit/cliconstants.nim +++ b/src/pit/cliconstants.nim @@ -1,4 +1,4 @@ -const PIT_VERSION* = "4.30.0" +const PIT_VERSION* = "4.30.1" const USAGE* = """Usage: pit ( new | add) [] [options] @@ -235,4 +235,4 @@ Issue Properties: If present, expected to be a comma-delimited list of text tags. The -g option is a short-hand for '-p tags:'. -""" +""" \ No newline at end of file diff --git a/src/pit/projects.nim b/src/pit/projects.nim index 8f05771..c6ea050 100644 --- a/src/pit/projects.nim +++ b/src/pit/projects.nim @@ -1,5 +1,5 @@ -import std/[algorithm, json, jsonutils, options, os, sets, strutils, tables, terminal, - times, unicode, wordwrap] +import std/[algorithm, json, jsonutils, options, os, sets, strutils, tables, + terminal, times, unicode, wordwrap] from std/sequtils import repeat, toSeq import cliutils, uuids, zero_functional import ./[formatting, libpit] @@ -256,8 +256,7 @@ proc formatMilestone*( result.add(withColor("─".repeat(availWidth), fgWhite)) var parentsToChildren = issues --> - filter(it.hasProp("parent")) --> - group(it["parent"]) + filter(it.hasProp("parent")).group(it["parent"]) var issuesToFormat = sorted(issues, cmp) --> filter(not it.hasProp("parent")) @@ -282,7 +281,7 @@ proc findShortestColumn(columns: seq[seq[string]]): int = proc joinColumns(columns: seq[seq[string]], columnWidth: int): seq[string] = - let maxLines = columns --> map(it.len) --> max() + let maxLines = columns --> map(it.len).max() for lineNo in 0 ..< maxLines: var newLine = "" @@ -316,7 +315,7 @@ proc showProject*(ctx: CliContext, project: Project) = fgBlue, bold=true)) let milestoneTexts: seq[seq[string]] = project.milestoneOrder --> - filter(project.milestones.hasKey(it) and project.milestones[it].len > 0) --> + filter(project.milestones.hasKey(it) and project.milestones[it].len > 0). map(ctx.formatMilestone(it, project.milestones[it], columnWidth)) var columns: seq[seq[string]] = repeat(newSeq[string](), numColumns) @@ -347,8 +346,16 @@ proc showProjectBoard*(ctx: CliContext, filter = none[IssueFilter]()) = let projectsCfg = ctx.loadProjectsConfiguration() let projectsDb = ctx.buildDb(projectsCfg) - for (context, projects) in pairs(projectsDb): - if projectsDb.len > 1: + var contextsAndProjects: seq[(string, seq[Project])] = @[] + + for (context, pjs) in pairs(projectsDb): + let projects = pjs + let issues: seq[Issue] = projects --> map(toSeq(values(it.milestones))).flatten().flatten() + if issues.len > 0: + contextsAndProjects.add((context, projects)) + + for (context, projects) in contextsAndProjects: + if contextsAndProjects.len > 1: stdout.writeLine("") stdout.writeLine(withColor( ctx.getIssueContextDisplayName(context) & ":",