From 6c69c6d6c8f02f750ef77851f661652b5a34b3fe Mon Sep 17 00:00:00 2001 From: simonwt Date: Tue, 31 Mar 2026 10:25:52 +0100 Subject: [PATCH] List posts by branch --- jobs/post/__init__.py | 2 +- jobs/post/listbybranch.py | 12 ++++++++++++ testing.py | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 jobs/post/listbybranch.py diff --git a/jobs/post/__init__.py b/jobs/post/__init__.py index 73717f8..44341ea 100644 --- a/jobs/post/__init__.py +++ b/jobs/post/__init__.py @@ -1,2 +1,2 @@ from .get import get -from .get import get \ No newline at end of file +from .listbybranch import listbybranch \ No newline at end of file diff --git a/jobs/post/listbybranch.py b/jobs/post/listbybranch.py new file mode 100644 index 0000000..29fd893 --- /dev/null +++ b/jobs/post/listbybranch.py @@ -0,0 +1,12 @@ +def listbybranch(API, branch_slug: str,) -> dict: + """ + Fetches the list of posts for a given branch from the API. + + Args: + branch_slug (str): Slug of the branch to fetch posts for. + Returns: + dict: The list of posts for the branch. + """ + print(f"Fetching posts for branch: {branch_slug}") + post_list = API.make_request("GET", "content", f"post/ref-subwiki/{branch_slug}", authenticate=True) + return post_list \ No newline at end of file diff --git a/testing.py b/testing.py index cbc4f97..8dc64ef 100644 --- a/testing.py +++ b/testing.py @@ -31,11 +31,14 @@ if not API.is_token_valid(): with open("token_data.json", "w") as f: json.dump(tokendata, f, indent=4) -profile = API.run_job('userprofile.get', "simon-little") -print(profile) -print("-----------------------------") -branch = API.run_job('branch.get', "music") -print(branch) -print("-----------------------------") -post = API.run_job('post.get', "1774875037-170a46a9") -print(post) \ No newline at end of file +# profile = API.run_job('userprofile.get', "simon-little") +# print(profile) +# print("-----------------------------") +# branch = API.run_job('branch.get', "music") +# print(branch) +# print("-----------------------------") +# post = API.run_job('post.get', "1774875037-170a46a9") +# print(post) +# print("-----------------------------") +feed = API.run_job('post.listbybranch', "music") +print(feed) \ No newline at end of file