Skip to content

feat(admin-stats): active orgs per post creation source - #1997

Merged
giladresisi merged 2 commits into
mainfrom
admin-daily-account-stats
Sep 15, 2026
Merged

giladresisi merged 2 commits into
mainfrom
admin-daily-account-stats

Conversation

@giladresisi

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

Feature (backend + frontend, super-admin stats page). Adds a new activeOrgsBySource block to the /admin/stats response: the number of distinct organizations with at least one top-level post in the selected range whose state is QUEUE, PUBLISHED or ERROR, grouped by Post.creationMethod (WEB / API / MCP / CLI / AUTOPOST / UNKNOWN). Implemented as sourceStats() in admin-stats.repository.ts (a single Prisma groupBy on organizationId + creationMethod, folded into per-source sets like the existing accountStats) and wired into getStats(). The frontend admin-stats.component.tsx renders it as one more summary card ("Unique users - active (all sources combined)") and one more table ("Active users per source"). Existing fields, params, gating, service and controller are unchanged; no schema change.

Why was this change needed?

We want to see, per day, how many organizations actually use Postiz through each entry point (web UI, public API, MCP, CLI), not only how many posts exist. The total is distinct across all sources (an org using both web and API on one day counts once), while each source row counts that org once, so the table always accounts for the total. Posts created before the creationMethod column existed (2026-05-12) show up under UNKNOWN.

Other information:

Drafts and soft-deleted posts are excluded. Back-filling creationMethod for old posts is out of scope.

QA

  1. Log in as a super admin and open /admin/stats with the "Today" preset; note the new card "Unique users - active (all sources combined)" and the table "Active users per source" at the end of each row
  2. From the web UI, schedule a post for today; from the public API (POST /public/v1/posts, same org), schedule one post for today and two posts for the day after tomorrow, one of them with "creationMethod": "CLI"; via MCP (integrationSchedulePostTool) schedule one for the day after tomorrow
  3. Today: the table shows WEB 1 and API 1, the card shows 1 (same org on two sources counts once in the total)
  4. Day after tomorrow: the table shows API 1, CLI 1, MCP 1, card 1
  5. Create a draft and delete another scheduled post on that day; the numbers do not change
  6. Schedule a post via the API from a second organization on the same day; that day's API row becomes 2 and the card becomes 2
  7. Select a multi-day range covering all of the above; each row shows the distinct org count across the range, and the card is the distinct total across all sources
  8. Existing cards/tables on the page show the same values as before

Checklist:

  • I have read the CONTRIBUTING guide.
  • I have signed the Contributor License Agreement (CLA) (ICLA for individuals, CCLA for entities).
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue
  • I have filled in the QA section above with real steps to verify this change.

@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Aug 31, 2026
@strix-security

strix-security Bot commented Aug 31, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 3260cd3.


Reviewed by Strix
Re-run review · Configure security review settings

@postiz-agent

postiz-agent Bot commented Aug 31, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@postiz-contribution
postiz-contribution Bot changed the base branch from staging to main August 31, 2026 10:58
@postiz-contribution
postiz-contribution Bot changed the base branch from main to staging September 1, 2026 08:29
Adds activeOrgsBySource to /admin/stats (distinct orgs with a QUEUE, PUBLISHED or ERROR post in the range, grouped by Post.creationMethod) and renders it as a summary card and table on the admin stats page.
@giladresisi
giladresisi force-pushed the admin-daily-account-stats branch from c491393 to d0c5d7c Compare September 1, 2026 08:38
@giladresisi
giladresisi changed the base branch from staging to main September 1, 2026 08:38
@postiz-contribution
postiz-contribution Bot changed the base branch from main to staging September 1, 2026 08:38
@postiz-contribution
postiz-contribution Bot changed the base branch from staging to main September 1, 2026 11:25
@giladresisi
giladresisi added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit 6376fd9 Sep 15, 2026
12 checks passed
@giladresisi
giladresisi deleted the admin-daily-account-stats branch September 15, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant