Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KDwevedi committed Jan 29, 2024
1 parent 51e67b8 commit f2c9288
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 154 deletions.
6 changes: 3 additions & 3 deletions cogs/badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ def get_user_badges(self, discord_id):
github_id = contributorData[0]["github_id"]
prData = {
"raised": SupabaseClient().read(
table="pull_requests", query_key="raised_by", query_value=github_id
table="connected_prs", query_key="raised_by", query_value=github_id
),
"merged": SupabaseClient(table="pull_requests").read(
table="pull_requests", query_key="merged_by", query_value=github_id
"merged": SupabaseClient(table="connected_prs").read(
table="connected_prs", query_key="merged_by", query_value=github_id
),
}
points = 0
Expand Down
18 changes: 12 additions & 6 deletions cogs/serverManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ async def getServerData(self, ctx):
# add all chapters
chapterRoles = []
guild = self.bot.get_guild(serverConfig.SERVER)
## Clear Error
oldRole = guild.get_role(973852365188907048)
print("started")
print(f"{len(oldRole.members)} have the old contributor role")
for member in oldRole.members:
print(member.joined_at)
if member.joined_at.timestamp() > datetime(2022, 12, 25).timestamp():
await member.remove_roles(oldRole, reason="mistakenly given")
print("Member removed")

for role in guild.roles:
if role.name.startswith("College:"):
orgName = role.name[len("College: ") :]
Expand All @@ -43,23 +53,17 @@ async def getServerData(self, ctx):
contributorsDiscord = SupabaseClient().read_all("contributors_discord")

## Give contributor role
print(1)
contributorIds = [
contributor["discord_id"] for contributor in contributorsGithub
]
print(2)
contributorRole = guild.get_role(serverConfig.Roles.CONTRIBUTOR_ROLE)
print(3)
count = [0, 0, 0]
for member in guild.members:
count[0] += 1
if member.id in contributorIds:
count[1] += 1
if contributorRole not in member.roles:
print(contributorRole)
print(member.roles)
count[2] += 1
print(4)
await member.add_roles(contributorRole)

print(count)
Expand All @@ -68,8 +72,10 @@ async def getServerData(self, ctx):
recordedMembers = [
contributor["discord_id"] for contributor in contributorsDiscord
]
print(f"{len(recordedMembers)} have their data saved")
currentMembers = [member.id for member in guild.members]
membersWhoLeft = list(set(recordedMembers) - set(currentMembers))
print(f"{len(membersWhoLeft)} members left")
SupabaseClient().deleteContributorDiscord(membersWhoLeft)
print("Updated Contributors")

Expand Down
16 changes: 2 additions & 14 deletions cogs/userInteractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,6 @@ async def github_profile(self, ctx):
```[![C4GTGithubDisplay](https://kcavhjwafgtoqkqbbqrd.supabase.co/storage/v1/object/public/c4gt-github-profile/{ctx.author.id}githubdisplay.jpg)](https://github.com/Code4GovTech)
Know more about: Code For GovTech ([Website](https://www.codeforgovtech.in) | [GitHub](https://github.com/Code4GovTech/C4GT/wiki)) | [Digital Public Goods (DPGs)](https://digitalpublicgoods.net/digital-public-goods/) | [India & DPGs](https://government.economictimes.indiatimes.com/blog/digital-public-goods-digital-public-infrastructure-an-evolving-india-story/99532036)```"""
)
# githubProfileInfoEmbed.set_footer(text="Respond with 🏆 to get the link")
# message = await ctx.send(embed=githubProfileInfoEmbed)
# await message.add_reaction("🏆")
# def check(reaction, user):
# return user == ctx.message.author and str(reaction.emoji) in ['🏆']
# try:
# reaction, user = await self.bot.wait_for('reaction_add', timeout=60.0, check=check)
# except asyncio.TimeoutError:
# await ctx.send("You took too long to respond.")
# else:
# if str(reaction.emoji) == '🏆':
# await ctx.send(f'[![C4GTGithubDisplay](https://kcavhjwafgtoqkqbbqrd.supabase.co/storage/v1/object/public/c4gt-github-profile/{ctx.author.id}githubdisplay.jpg?maxAge=10)](https://github.com/Code4GovTech)')

@update_contributors.before_loop
async def before_update_loop(self):
Expand Down Expand Up @@ -406,10 +394,10 @@ async def get_points(self, ctx):
print(contributor)
github_id = contributor[0]["github_id"]
prs_raised = SupabaseClient().read(
table="pull_requests", query_key="raised_by", query_value=github_id
table="connected_prs", query_key="raised_by", query_value=github_id
)
prs_merged = SupabaseClient().read(
table="pull_requests", query_key="merged_by", query_value=github_id
table="connected_prs", query_key="merged_by", query_value=github_id
)
raise_points = 0
merge_points = 0
Expand Down
Empty file removed models/__init__.py
Empty file.
59 changes: 0 additions & 59 deletions models/product.py

This file was deleted.

39 changes: 0 additions & 39 deletions models/project.py

This file was deleted.

33 changes: 0 additions & 33 deletions models/user.py

This file was deleted.

0 comments on commit f2c9288

Please sign in to comment.