-3

SO has badges that are awarded to users for completing some tasks. I was playing around with SO Data Explorer and noticed there is no table for badge definition itself.

So for example if I want to figure out list of users who received a 'Moderation Badge', I need to scrape a list from Badges page then build the query.

Same way if I need to build a page showing list of badges, with explanation of badge and who received it first, again I need to scrape the badges page and build it manually.

Question

Is there a table that holds the badge name, its description, retired status, And if there is one, would it be possible to include it in data explorer, please?

Or in other words, where the data for Badges specifically description and category of each badge coming from. Stackoverflow is an example and would be nice if I could get data for badge description and category for all SE sites.

Note that:

13
  • 1
    It could very well be that these are hardcoded strings (or rather translatable ones) in the site's source code. OTOH, we do have tables like PostNoticeTypes and ReviewRejectionReasons in SEDE.
    – Glorfindel Mod
    Commented Oct 27 at 13:57
  • I should've simplified my question by saying how the Badges page is made? Is it generated or manually created Automatically?
    – AaA
    Commented Oct 27 at 14:01
  • 1
    SEDE lacks that data but the API has it, to some extent: meta.stackexchange.com/questions/402558/… (if it wasn't broken)
    – rene Mod
    Commented Oct 27 at 14:56
  • 3
    "I should've simplified my question by..." you still can do it as there isn't any answer. Please edit the question to clarify what you are asking / what you expect as an answer.
    – Rubén
    Commented Oct 27 at 16:13
  • @rene, API doesn't seem to let me choose name types only excluding tag_based ones
    – AaA
    Commented Oct 27 at 19:22
  • @Rubén, The question is exactly what I need. How the badges page is made is not important. I need category and description of named badges which in that page is specified but its data does not exist in SEDE
    – AaA
    Commented Oct 27 at 19:23
  • Question is what do you need it for? What are you doing with the data? Commented Oct 27 at 20:08
  • It's funny how you guys keep closing the questions by linking it to an unrelated question. I have already read that question and it is not an answer
    – AaA
    Commented Oct 28 at 4:27
  • The thing is, it may be the best answer available at present - the answer there delineates the limits of our knowledge of the internal workings of SE and the limits of our access to that data. Without actually paying SE for more data, that's all we know.
    – W.O.
    Commented Oct 28 at 6:24
  • I'm sorry, but by closing question, you are not allowing it to have a better answer. There is two mod already looked at this before you guys decided it is better close the question and bury it.
    – AaA
    Commented Oct 28 at 8:19
  • 2
    We would have known if there were a better answer. We close duplicates. If something comes to light, then if you follow the dupe target, you'll get notified. If you feel that the issue is something that needs attention drawn to it, then you can offer a bounty on the dupe target and request an authoritative answer - if a member of staff decides to share, then.....
    – W.O.
    Commented Oct 28 at 8:35
  • Well, I'm positive that there is a table for badge and I'm also positive that it is not included in the Data Explorer. Thanks to multiple edits by different users trying to make it better, it completely changed from what I was asking (which was include badge info in SEDE which is a feature request to a discussion (tags changed too)
    – AaA
    Commented Oct 29 at 12:14
  • Oh, I'd not realized that. On the face of it that seems like a reasonable feature request. Not sure why the edit then. I've no idea why that would be then.
    – W.O.
    Commented Oct 29 at 14:49

1 Answer 1

4

There is no such table in the SEDE schema.

if you look at the result for my gold badges in this query

select *
from badges
where userid = 578411
and tagbased = 0
and class = 1 -- gold

you'll find

Id UserId Name Date Class TagBased
7419206 578411 Copy Editor 2013-09-04 22:19:13 1 False
7912782 578411 Marshal 2013-10-26 23:52:04 1 False
5096365 578411 Electorate 2012-12-22 15:31:48 1 False

For most other tables the primary key Id is usable in one way or the other in a route url on the site (comments, posts, users, reviews, suggestededits)

I don't know the actual schema used in production but I imagine it is along these lines:

 + ------------+         +-------------+
 | UserBadge   |         | BadgeTypes  |
 |-------------|         |-------------|
 | Id          |\        | Id          |
 | UserId      |--o----- | Name        |
 | BadgeTypeId |/        | Description | 
 | Date        |         | Class       |
 +-------------+         | TagBased    |
                         | Created     |
                         | Retired     |
                         +-------------+

The SEDE export "Badges" is probably a view over these tables. It is specifically a shame that the BadgeTypes.Id isn't included because without it you can't create a link for the specific user to the specific badge. For my Marshal badge the url would be:

https://stackoverflow.com/help/badges/1298/marshal?userid=578411

but we don't have that pesky 1298 so no magic links from SEDE are possible.

I don't know what the rationale back then was to omit the BadgeTypes table. I can see how it helps for some minor interesting queries like lead-time to first badge after introduction. And it would help building a magic link. I'm not sure that is enough motivation to justify the effort needed for adding this table to SEDE.

1
  • Thanks for answer, I was actually looking for the description of each badge in badges and total badges introduced in each sub site. I'm guessing that UserBadge table should at least have a description column too. Since I didn't get my hand on the data (feature request) I scraped the pages and got the description Since I couldn't get my hands
    – AaA
    Commented Nov 29 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .