messageCount: Add docs

This commit is contained in:
Wroclaw 2023-09-21 09:23:47 +02:00
parent 339ef06ff9
commit e194c1d81a

View file

@ -11,6 +11,10 @@ export default class MessageCount implements IQuota {
lookback: number;
defaultQuota: number;
/**
* @param defaultQuota the default quota for users that don't have override
* @param lookback lookback to check
*/
constructor(
defaultQuota: number = 25,
lookback: number = 1000 * 60 * 60 * 24
@ -19,6 +23,9 @@ export default class MessageCount implements IQuota {
this.lookback = lookback;
}
/**
* Retrives the quota from the database
*/
private getUserQuota(id: string) {
return database.limits.findUnique({
where: { user: BigInt(id) },
@ -78,6 +85,9 @@ export default class MessageCount implements IQuota {
};
}
/**
* helper funtion to create userQuotaData
*/
private createUserQuotaData(quota: number, used: number): userQuotaData {
const humanReadable = milisecondsToHumanReadable(this.lookback);
return {