# An automatic group of group owners

**URL:** https://meta.discourse.org/t/an-automatic-group-of-group-owners/144633
**Category:** Feature
**Created:** [17 במרץ,‏ 2020,‏ 7:52pm UTC](https://meta.discourse.org/t/an-automatic-group-of-group-owners/144633 "2020-03-17T19:52:02Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [13 באוגוסט,‏ 2022,‏ 2:33am UTC](https://meta.discourse.org/t/an-automatic-group-of-group-owners/144633/2 "2022-08-13T02:33:43Z")

</div>

I’ve just implemented a [Creating triggered custom badge queries](https://meta.discourse.org/t/triggered-custom-badge-queries/19336) for identifying current group owners.

The SQL for it is here (can be used in [Data Explorer](https://meta.discourse.org/t/32566?silent=true) too)

```sql
SELECT DISTINCT user_id, owner, CURRENT_TIMESTAMP granted_at
FROM group_users
WHERE group_users.owner = true

```

It uses `CURRENT_TIMESTAMP` as there is no nice convenient timestamp for group ownership in the database that I can see. There is no nice trigger either so the `:backfill` thing can be omitted

I suggest this config:

1. Run revocation query daily
2. Trigger: Update daily
3. I’m not sure about ‘Can be granted multiple times’  
The query only fires once for each user so multiple won’t be granted. But it might be needed to have the badge granted again once revoked - no sure!

---

_[View the full topic](https://meta.discourse.org/t/an-automatic-group-of-group-owners/144633)._
