Skip to content

Add Contributions Command #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LaurenceWarne
Copy link

Hi!

I thought it would be cool to check which problems people have contributed to, and I think whether a user is a contributor to a problem can now be recognised to some extent (though not through the minimal api!) since they will no longer appear on the top solvers list. In a bit more detail:

Get the time the user solved a problem from their recent solves history, is this less than the most recent solver in the top 100 and are they absent from the top solvers list?

The main function added is is_contributor:

is_contributor("heteroing", 821) # True 
is_contributor("__LW__", 821)    # False
is_contributor("heteroing", 822) # False
is_contributor("__LW__", 822)    # False

Which the new command basically delegates to.
This PR persists the contributions a user has made, I can only guess the schema from the sql snippets, but I think something along the lines of this should work:

CREATE TABLE IF NOT EXISTS problem_contributions (
  username VARCHAR(255) NOT NULL,
  problem INT NOT NULL,
  PRIMARY KEY (username, problem),
  FOREIGN KEY (username) REFERENCES members(username) ON DELETE CASCADE
);

I've been able to test is_contributor, but I don't really know enough about discord and it's API to test the levels above that, hopefully this is interesting nontheless.

Thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant