-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes for migration to be postgres to be merged to main #86
base: main
Are you sure you want to change the base?
Changes from 8 commits
102103b
0c23308
2908558
20eee57
353b425
1f6976c
5404627
4799c8e
d36cb2e
c20b815
83c4199
469f82a
3364a90
6a70571
cd8c28b
ec6de60
3644aed
ced3991
8b7aaf4
23c444e
92e9af3
0fd0464
74486e9
163e7d7
3dfb1e8
bc255cc
4a0f5de
7319844
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import discord | ||
from discord.ext import commands | ||
|
||
from helpers.supabaseClient import SupabaseClient | ||
from helpers.supabaseClient import PostgresClient | ||
|
||
|
||
class BadgeModal(discord.ui.Modal, title="Your Badges"): | ||
|
@@ -133,7 +133,7 @@ def get_user_badges(self, discord_id): | |
userBadges = {"points": [], "achievements": []} | ||
if ( | ||
len( | ||
SupabaseClient().read( | ||
PostgresClient().read( | ||
"contributors_registration", | ||
query_key="discord_id", | ||
query_value=discord_id, | ||
|
@@ -143,7 +143,7 @@ def get_user_badges(self, discord_id): | |
): | ||
userBadges["achievements"].append(self.discordXGithubBadge) | ||
|
||
discordMemberData = SupabaseClient().read( | ||
discordMemberData = PostgresClient().read( | ||
"discord_engagement", "contributor", discord_id | ||
) | ||
if discordMemberData: | ||
|
@@ -153,16 +153,16 @@ def get_user_badges(self, discord_id): | |
userBadges["achievements"].append(self.rockstarBadge) | ||
if discordMemberData[0]["has_introduced"]: | ||
userBadges["achievements"].append(self.apprenticeBadge) | ||
contributorData = SupabaseClient().read( | ||
contributorData = PostgresClient().read( | ||
"contributors_registration", query_key="discord_id", query_value=discord_id | ||
) | ||
if contributorData: | ||
github_id = contributorData[0]["github_id"] | ||
prData = { | ||
"raised": SupabaseClient().read( | ||
"raised": PostgresClient().read( | ||
table="connected_prs", query_key="raised_by", query_value=github_id | ||
), | ||
"merged": SupabaseClient(table="connected_prs").read( | ||
"merged": PostgresClient(table="connected_prs").read( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a different syntax. We should have a uniform syntax across the board. |
||
table="connected_prs", query_key="merged_by", query_value=github_id | ||
), | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
from discord.channel import TextChannel | ||
from discord.ext import commands, tasks | ||
|
||
from helpers.supabaseClient import SupabaseClient | ||
from helpers.supabaseClient import PostgresClient | ||
|
||
with open("config.json") as config_file: | ||
config_data = json.load(config_file) | ||
|
@@ -28,12 +28,12 @@ def __init__(self, bot) -> None: | |
@commands.Cog.listener() | ||
async def on_message(self, message): | ||
pass | ||
# contributor = SupabaseClient().read( | ||
# contributor = PostgresClient().read( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets delete the commented code. |
||
# "discord_engagement", "contributor", message.author.id | ||
# ) | ||
# print("message", len(message.content)) | ||
# if not contributor: | ||
# SupabaseClient().insert( | ||
# PostgresClient().insert( | ||
# "discord_engagement", | ||
# { | ||
# "contributor": message.author.id, | ||
|
@@ -46,13 +46,13 @@ async def on_message(self, message): | |
# if len(message.content) > 20: | ||
# if message.channel.id == INTRODUCTIONS_CHANNEL_ID: | ||
# print("intro") | ||
# SupabaseClient().update( | ||
# PostgresClient().update( | ||
# "discord_engagement", | ||
# {"has_introduced": True}, | ||
# "contributor", | ||
# message.author.id, | ||
# ) | ||
# SupabaseClient("discord_engagement").update( | ||
# PostgresClient("discord_engagement").update( | ||
# "discord_engagement", | ||
# {"total_message_count": contributor[0]["total_message_count"] + 1}, | ||
# "contributor", | ||
|
@@ -62,11 +62,11 @@ async def on_message(self, message): | |
@commands.Cog.listener() | ||
async def on_reaction_add(self, reaction, user): | ||
message = reaction.message | ||
contributor = SupabaseClient().read( | ||
contributor = PostgresClient().read( | ||
"discord_engagement", "contributor", message.author.id | ||
)[0] | ||
if not contributor: | ||
SupabaseClient().insert( | ||
PostgresClient().insert( | ||
"discord_engagement", | ||
{ | ||
"contributor": message.author.id, | ||
|
@@ -77,7 +77,7 @@ async def on_reaction_add(self, reaction, user): | |
) | ||
return | ||
print("reaction") | ||
SupabaseClient().update( | ||
PostgresClient().update( | ||
"discord_engagement", | ||
{"total_reaction_count": contributor["total_reaction_count"] + 1}, | ||
"contributor", | ||
|
@@ -89,7 +89,7 @@ async def add_engagement(self, ctx): | |
await ctx.channel.send("started") | ||
|
||
def addEngagmentData(data): | ||
client = SupabaseClient() | ||
client = PostgresClient() | ||
client.insert("discord_engagement", data) | ||
return | ||
|
||
|
@@ -145,7 +145,7 @@ async def enable_webhook(self, ctx): | |
channels = await guild.fetch_channels() | ||
enabled = [ | ||
channel["channel_id"] | ||
for channel in SupabaseClient().read_all("discord_channels") | ||
for channel in PostgresClient().read_all("discord_channels") | ||
] | ||
for channel in channels: | ||
try: | ||
|
@@ -156,7 +156,7 @@ async def enable_webhook(self, ctx): | |
webhook = await channel.create_webhook(name="New Ticket Alert") | ||
feedback = f"""URL: {webhook.url}\n Token:{"Yes" if webhook.token else "No"}""" | ||
await ctx.send(feedback) | ||
SupabaseClient().insert( | ||
PostgresClient().insert( | ||
"discord_channels", | ||
{ | ||
"channel_id": channel.id, | ||
|
@@ -177,7 +177,7 @@ async def update_applicants(self, ctx): | |
await ctx.send("Member List Count: " + str(len(members))) | ||
for member in members: | ||
try: | ||
SupabaseClient().insert( | ||
PostgresClient().insert( | ||
"applicant", | ||
{"sheet_username": member.name, "discord_id": member.id}, | ||
) | ||
|
@@ -216,12 +216,12 @@ async def collect_all_messages(self): | |
|
||
async def add_messages(self): | ||
def addMessageData(data): | ||
client = SupabaseClient() | ||
client = PostgresClient() | ||
client.insert("unstructured discord data", data) | ||
return | ||
|
||
def getLastMessageObject(channelId): | ||
last_message = SupabaseClient().read_by_order_limit( | ||
last_message = PostgresClient().read_by_order_limit( | ||
table="unstructured discord data", | ||
query_key="channel", | ||
query_value=channelId, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
from helpers.supabaseClient import SupabaseClient | ||
from helpers.supabaseClient import PostgresClient | ||
|
||
|
||
class RoleEventsListener(commands.Cog): | ||
|
@@ -13,27 +13,27 @@ def __init__(self, bot) -> None: | |
async def on_guild_role_create(self, role: discord.Role): | ||
if role.name.startswith("College:"): | ||
orgName = role.name[len("College: ") :] | ||
SupabaseClient().addChapter(roleId=role.id, orgName=orgName, type="COLLEGE") | ||
PostgresClient().addChapter(roleId=role.id, orgName=orgName, type="COLLEGE") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class level instance here as well. Lets do it for all classes. |
||
elif role.name.startswith("Corporate:"): | ||
orgName = role.name[len("Corporate: ") :] | ||
SupabaseClient().addChapter( | ||
PostgresClient().addChapter( | ||
roleId=role.id, orgName=orgName, type="CORPORATE" | ||
) | ||
|
||
@commands.Cog.listener() | ||
async def on_guild_role_delete(self, role: discord.Role): | ||
SupabaseClient().deleteChapter(roleID=role.id) | ||
PostgresClient().deleteChapter(roleID=role.id) | ||
|
||
@commands.Cog.listener() | ||
async def on_guild_role_update(self, before: discord.Role, after: discord.Role): | ||
if after.name.startswith("College:"): | ||
orgName = after.name[len("College: ") :] | ||
SupabaseClient().addChapter( | ||
PostgresClient().addChapter( | ||
roleId=after.id, orgName=orgName, type="COLLEGE" | ||
) | ||
elif after.name.startswith("Corporate:"): | ||
orgName = after.name[len("Corporate: ") :] | ||
SupabaseClient().addChapter( | ||
PostgresClient().addChapter( | ||
roleId=after.id, orgName=orgName, type="CORPORATE" | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create 1 class level instance of postgresclient please? Creating a new one each time seems unncessary.