import dayjs from "dayjs";
import DB from "src/system/DB";
import { getDate } from "taehui-ts/date";

import { isBannedIP } from "src/Utility";

export const getHit = async () => {
  return DB.getHit(getDate(), dayjs().subtract(1, "day").format("YYYY-MM-DD"));
};

export const postHit = async (avatarIP: string) => {
  if (isBannedIP(avatarIP)) {
    return false;
  } else {
    return DB.postHit(avatarIP, getDate());
  }
};
