You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO: Add more detailed stats on cases, add stats on reminders and level system
# iterate down the guildlist and run logging for each entry
fromdiscord.extimportcommands, tasksfrominfluxdb_client.client.influxdb_clientimportInfluxDBClientfrominfluxdb_client.client.write.pointimportPointfrominfluxdb_client.client.write_apiimportSYNCHRONOUSfromloguruimportloggerfromtux.botimportTuxfromtux.database.clientimportdbfromtux.utils.configimportCONFIGclassInfluxLogger(commands.Cog):
def__init__(self, bot: Tux):
self.bot=botifself.init_influx():
self.logger.start()
else:
logger.error("influxdb logger failed to init. check .env")
definit_influx(self):
influx_token: str=CONFIG.INFLUXDB_TOKENinflux_url: str=CONFIG.INFLUXDB_URLself.influx_org: str=CONFIG.INFLUXDB_ORGif (influx_token!="") and (influx_url!="") and (self.influx_org!=""):
write_client=InfluxDBClient(url=influx_url, token=influx_token, org=self.influx_org)
self.influx_write_api=write_client.write_api(write_options=SYNCHRONOUS) # pyright:ignore[reportUnknownMemberType]returnTruereturnFalse@tasks.loop(seconds=60)asyncdeflogger(self):
influx_bucket="tux stats"# Collect the guild list from the database, we'll need this to sort everything by.guild_list=awaitdb.guild.find_many()
# TODO: Add more detailed stats on cases, add stats on reminders and level system# iterate down the guildlist and run logging for each entryforiinguild_list:
# Collect data by querying the db and filtering results to only include the guild we're currently working onstarboard_stats=awaitdb.starboardmessage.find_many(
where={
"message_guild_id": i.guild_id,
},
)
snippet_stats=awaitdb.snippet.find_many(
where={
"guild_id": i.guild_id,
},
)
afk_stats=awaitdb.afkmodel.find_many(
where={
"guild_id": i.guild_id,
},
)
case_stats=awaitdb.case.find_many(
where={
"guild_id": i.guild_id,
},
)
points: list[Point] = [
Point("guild stats").tag("guild", i.guild_id).field("starboard count", len(starboard_stats)), # pyright:ignore[reportUnknownMemberType]Point("guild stats").tag("guild", i.guild_id).field("snippet count", len(snippet_stats)), # pyright:ignore[reportUnknownMemberType]Point("guild stats").tag("guild", i.guild_id).field("afk count", len(afk_stats)), # pyright:ignore[reportUnknownMemberType]Point("guild stats").tag("guild", i.guild_id).field("case count", len(case_stats)), # pyright:ignore[reportUnknownMemberType]
]
self.influx_write_api.write(bucket=influx_bucket, org=self.influx_org, record=points) # pyright:ignore[reportUnknownMemberType]asyncdefsetup(bot: Tux) ->None:
awaitbot.add_cog(InfluxLogger(bot))
The text was updated successfully, but these errors were encountered:
iterate down the guildlist and run logging for each entry
tux/tux/cogs/services/influxdblogger.py
Lines 35 to 36 in c77006c
The text was updated successfully, but these errors were encountered: