Skip to content

Commit e3f3376

Browse files
authored
feat: Fix issue pull limits and add filter out done (#90)
Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
1 parent a6cfec4 commit e3f3376

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/static_site_generator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self):
1515
'tasks': []
1616
}
1717

18-
def generate_site(self, data:list=None, projects:list[str]=None, output_file='./_site/index.html') -> None:
18+
def generate_site(self, data:list=None, filter_done:bool=False, projects:list[str]=None, output_file='./_site/index.html') -> None:
1919
logging.info("Generating Static Site")
2020
env = Environment(loader=FileSystemLoader('templates'))
2121
template = env.get_template('kaban_board.html')
@@ -34,9 +34,14 @@ def generate_site(self, data:list=None, projects:list[str]=None, output_file='./
3434
for task in self.GENERATOR_DATA["tasks"]:
3535
if "status" not in task:
3636
task["status"] = "NONE"
37+
elif task["status"].upper() == "DONE" and filter_done == True:
38+
# remove the task from the list
39+
self.GENERATOR_DATA["tasks"].remove(task)
40+
continue
3741
else:
3842
task["status"] = task["status"].upper()
3943
statuses.add(task["status"])
44+
print(f"[bold cyan]Adding {len(self.GENERATOR_DATA["tasks"])} tasks to the site[/bold cyan]")
4045

4146
# Extract unique statuses from the tasks list
4247
unique_statuses:list[str] = sorted(statuses)

src/version2config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def init_parser(self):
3737
help="The temporary directory to store the json data files"
3838
)
3939

40+
parser.add_argument(
41+
"--filter-done",
42+
dest="filter_done",
43+
action="store_true",
44+
help="Filter out all issues and PRs that are marked as done"
45+
)
46+
4047
parser.add_argument(
4148
"--include-project",
4249
dest="include_project",
@@ -176,6 +183,7 @@ def init_parser(self):
176183
self.exclude_label = parsed_args.exclude_label
177184
self.publish_board = parsed_args.publish_board
178185
self.exclude_team = parsed_args.exclude_team
186+
self.filter_done = parsed_args.filter_done if parsed_args.filter_done else False
179187

180188
def init_logger(self):
181189
logging.basicConfig(level=self.LOG_LEVEL, format=self.LOG_FORMAT)
@@ -187,6 +195,7 @@ def display_config(self):
187195
logging.info("Configuration:")
188196
logging.info(f"Output File: {self.output_file}")
189197
logging.info(f"Temporary Directory: {self.temp_dir}")
198+
logging.info(f"Filter Done: {self.filter_done}")
190199
logging.info(f"Include Project: {self.include_project}")
191200
logging.info(f"Include User: {self.include_user}")
192201
logging.info(f"Include Repository: {self.include_repository}")

src/version2query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88
from ghapi.all import GhApi
99
from rich import print
10+
from time import sleep
1011
from .queryFilter import QueryFilter
1112

1213
class Version2Query:
@@ -130,7 +131,9 @@ def fetch_project_items(self, projects:list[dict]) -> bool:
130131
# use os.system instead of subprocess.run or subprocess.popen to avoid creating a new
131132
# process space where we would need to copy environment variables into it (possibly
132133
# exposing things like GH_TOKEN or other environment variables)
133-
os.system( f'gh project item-list --owner "{org}" {number} --format json > "{out_path}"')
134+
# The default limit on the gh project item-list command is 30 items. We need to update
135+
# the limit to 1000 to get all items in the project.
136+
os.system( f'gh project item-list --owner "{org}" {number} --limit 1000 --format json > "{out_path}"')
134137

135138
if not out_path.exists():
136139
print(f"[red]Failed to fetch items for project: {title} (Org: {org}, Project: {number})[/red]")
@@ -148,6 +151,7 @@ def consolidate_items(self) -> bool:
148151
with open(file) as f:
149152
data = json.load(f)
150153
items = data.get("items", [])
154+
print(f"[green]Found {len(items)} items in {file}[/green]")
151155
all_items.extend(items)
152156
except Exception as e:
153157
print(f"[red]Error consolidating items: {e}[/red]")

version2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main():
4646
with open(output_file, 'r') as f:
4747
data = json.load(f)
4848

49-
ss_gen.generate_site(data=data, projects=filters["include_projects"])
49+
ss_gen.generate_site(data=data, filter_done=config.filter_done, projects=filters["include_projects"])
5050

5151
if __name__ == "__main__":
5252
main()

0 commit comments

Comments
 (0)