typeorm#MoreThanOrEqual TypeScript Examples
The following examples show how to use
typeorm#MoreThanOrEqual.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: middleware.ts From Corsace with MIT License | 6 votes |
async function currentMCA (ctx: ParameterizedContext, next: Next): Promise<any> {
const mca = await MCA.findOne({
results: MoreThanOrEqual(new Date()),
nomination: {
start: LessThanOrEqual(new Date()),
},
});
if (!mca) {
return ctx.body = {
error: "No MCA found for this year",
};
}
ctx.state.mca = mca;
await next();
}
Example #2
Source File: mca.ts From Corsace with MIT License | 6 votes |
static current (): Promise<MCA> {
const date = new Date();
return MCA.findOneOrFail({
results: MoreThanOrEqual(date),
nomination: {
start: LessThanOrEqual(date),
},
});
}
Example #3
Source File: mca.ts From Corsace with MIT License | 6 votes |
static currentOrLatest (): Promise<MCA | undefined> {
const date = new Date();
return MCA.findOne({
where: [
{
results: MoreThanOrEqual(date),
nomination: {
start: LessThanOrEqual(date),
},
},
{
year: date.getUTCFullYear() - 1,
},
],
order: {
results: "DESC",
},
});
}
Example #4
Source File: Consent.ts From ADR-Gateway with MIT License | 6 votes |
getActiveConsentByAccessToken = async (token:string,thumbprint:string,subjectPpid:string|undefined): Promise<Consent> => {
let resolvedConnection = (await this.connection);
let findOptions:any = {
accessToken: token,
clientCertThumbprint: thumbprint,
// subjectPpid: subjectPpid,
tokenRevocationStatus: Not(TokenRevocationStatus.REVOKED),
accessTokenExpires: MoreThanOrEqual(moment().utc().toDate())
};
if (subjectPpid) {findOptions.subjectPpid = subjectPpid}
let matchingConsent = await resolvedConnection.manager.findOneOrFail(
Consent,findOptions);
return matchingConsent;
}
Example #5
Source File: collections.service.ts From aqualink-app with MIT License | 6 votes |
async getHeatStressTracker() {
const heatStressData = await this.latestDataRepository.find({
metric: Metric.DHW,
value: MoreThanOrEqual(1),
});
const heatStressSiteIds = heatStressData.map((data) => data.siteId);
const heatStressSites = await this.siteRepository.find({
where: { id: In(heatStressSiteIds), approved: true },
});
return this.processCollection(heatStressTracker, heatStressSites);
}
Example #6
Source File: cve.ts From crossfeed with Creative Commons Zero v1.0 Universal | 6 votes |
identifyUnexpectedWebpages = async (allDomains: Domain[]) => {
const vulnerabilities: Vulnerability[] = [];
const webpages = await Webpage.find({
where: {
domain: { id: In(allDomains.map((e) => e.id)) },
status: MoreThanOrEqual(500)
},
relations: ['domain']
});
for (const webpage of webpages) {
vulnerabilities.push(
plainToClass(Vulnerability, {
domain: webpage.domain,
lastSeen: new Date(Date.now()),
title: `Unexpected status code ${webpage.status} for ${webpage.url}`,
severity: 'Low',
state: 'open',
source: 'webpage_status_code',
description: `${webpage.status} is not a normal status code that comes from performing a GET request on ${webpage.url}. This may indicate a misconfiguration or a potential for a Denial of Service (DoS) attack.`
})
);
}
await saveVulnerabilitiesToDb(vulnerabilities, false);
}
Example #7
Source File: paginate.ts From nestjs-paginate with MIT License | 6 votes |
OperatorSymbolToFunction = new Map<FilterOperator, (...args: any[]) => FindOperator<string>>([
[FilterOperator.EQ, Equal],
[FilterOperator.GT, MoreThan],
[FilterOperator.GTE, MoreThanOrEqual],
[FilterOperator.IN, In],
[FilterOperator.NULL, IsNull],
[FilterOperator.LT, LessThan],
[FilterOperator.LTE, LessThanOrEqual],
[FilterOperator.BTW, Between],
[FilterOperator.NOT, Not],
])
Example #8
Source File: influenceAdd.ts From Corsace with MIT License | 4 votes |
async function command (m: Message) {
const influenceAddRegex = /(inf|influence)add\s+(.+)/i;
const profileRegex = /(osu|old)\.ppy\.sh\/(u|users)\/(\S+)/i;
const modeRegex = /-(standard|std|taiko|tko|catch|ctb|mania|man|storyboard|sb)/i;
const commentRegex = /-c (.+)/i;
if (!influenceAddRegex.test(m.content)) {
await m.reply("Please at least provide a user come on!!!!!!");
return;
}
const user = await User.findOne({
discord: {
userID: m.author.id,
},
});
if (!user) {
await m.reply("No user found in the corsace database for you! Please login to https://corsace.io with your discord and osu! accounts!");
return;
}
// Get year, search, mode, and/or comment params
let comment = "";
if (commentRegex.test(m.content)) {
comment = commentRegex.exec(m.content)![1];
m.content = m.content.replace(commentRegex, "").trim();
}
const res = influenceAddRegex.exec(m.content);
if (!res)
return;
const params = res[2].split(" ");
let year = 0;
let search = "";
let mode: ModeDivision | undefined = undefined;
for (const param of params) {
if (/^20[0-9]{2}$/.test(param))
year = parseInt(param, 10);
if (year !== 0) {
search = params.filter(p => p !== param).join(" ");
break;
}
}
if (year === 0) {
year = (new Date).getUTCFullYear();
search = params.join(" ");
}
for (const param of params) {
if (modeRegex.test(param)) {
switch (modeRegex.exec(param)![1]) {
case "standard" || "std": {
mode = await ModeDivision.findOne(1);
break;
} case "taiko" || "tko": {
mode = await ModeDivision.findOne(2);
break;
} case "catch" || "ctb": {
mode = await ModeDivision.findOne(3);
break;
} case "mania" || "man": {
mode = await ModeDivision.findOne(4);
break;
} case "storyboard" || "sb": {
mode = await ModeDivision.findOne(5);
break;
}
}
if (mode) {
search = params.filter(p => p !== param).join(" ");
break;
}
}
}
if (!mode)
mode = await ModeDivision.findOne(1);
if (!isEligibleFor(user, mode!.ID, year)) {
await m.reply(`You did not rank a set or guest difficulty this year in **${mode!.name}**!${year === (new Date).getUTCFullYear() ? "\nFor adding influences in the current year, then if you have ranked a set, re-login to Corsace with your osu! account, and you should be able to add them after!" : ""}`);
return;
}
// Find user
let q = search;
let apiUser: APIUser;
if (profileRegex.test(search)) { // Profile linked
const res = profileRegex.exec(m.content);
if (!res)
return;
q = res[3];
apiUser = (await osuClient.user.get(res[3])) as APIUser;
} else
apiUser = (await osuClient.user.get(search)) as APIUser;
if (!apiUser) {
await m.reply(`No user found for **${q}**`);
return;
}
let influenceUser = await User.findOne({
osu: {
userID: apiUser.userId.toString(),
},
});
if (!influenceUser) {
influenceUser = new User;
influenceUser.country = apiUser.country.toString();
influenceUser.osu = new OAuth;
influenceUser.osu.userID = `${apiUser.userId}`;
influenceUser.osu.username = apiUser.username;
influenceUser.osu.avatar = "https://a.ppy.sh/" + apiUser.userId;
await influenceUser.save();
}
const influences = await Influence.find({
where: {
user,
year,
mode,
},
relations: ["user", "influence"],
});
if (influences.length === 5) {
await m.reply(`You already have 5 influences for **${year}** in **${mode!.name}**!`);
return;
} else if (influences.some(inf => inf.influence.osu.userID === influenceUser!.osu.userID)) {
await m.reply(`You have already marked **${influenceUser.osu.username}** as a mapping influence for **${year}** in **${mode!.name}**!`);
return;
}
const influence = new Influence;
influence.user = user;
influence.influence = influenceUser!;
influence.year = year;
influence.mode = mode!;
influence.comment = comment;
influence.rank = influences.length + 1;
// Warn for older years
const mca = await MCA.findOne({
results: MoreThanOrEqual(new Date()),
nomination: {
start: LessThanOrEqual(new Date()),
},
});
if (year < (mca ? mca.year : (new Date()).getUTCFullYear())) {
const row = new MessageActionRow();
row.addComponents(
new MessageButton()
.setCustomId("true")
.setLabel("Yes")
.setStyle("SUCCESS"),
new MessageButton()
.setCustomId("false")
.setLabel("No")
.setStyle("DANGER")
);
const message = await m.reply({
content: `Are you sure you want to add **${influenceUser.osu.username}** as a mapping influence for **${year}** in **${mode!.name}**? You cannot remove influences for years past the currently running MCA!`,
components: [row],
});
const collector = message.createMessageComponentCollector({ componentType: "BUTTON", time: 10000 });
collector.on("collect", async (i) => {
if (i.user.id !== m.author.id) {
i.reply({ content: "Fack off cunt", ephemeral: true });
return;
}
if (i.customId === "true") {
await influence.save();
m.reply(`Added **${influenceUser!.osu.username}** as a mapping influence for **${year}** in **${mode!.name}**!`);
}
await message.delete();
});
collector.on("end", async () => {
try {
await message.delete();
} catch (e) {
if (e instanceof DiscordAPIError)
return;
console.error(e);
}
});
return;
}
await influence.save();
m.reply(`Added **${influenceUser.osu.username}** as a mapping influence for **${year}** in **${mode!.name}**!`);
return;
}
Example #9
Source File: influenceRemove.ts From Corsace with MIT License | 4 votes |
async function command (m: Message) {
const influenceRemoveRegex = /(inf|influence)del(ete)?\s+(.+)/i;
const profileRegex = /(osu|old)\.ppy\.sh\/(u|users)\/(\S+)/i;
const modeRegex = /-(standard|std|taiko|tko|catch|ctb|mania|man|storyboard|sb)/i;
if (!influenceRemoveRegex.test(m.content)) {
await m.reply("Please provide a year and user it's not that hard!!!!!");
return;
}
const user = await User.findOne({
discord: {
userID: m.author.id,
},
});
if (!user) {
await m.reply("No user found in the corsace database for you! Please login to https://corsace.io with your discord and osu! accounts!");
return;
}
// Get year and/or search query params
const res = influenceRemoveRegex.exec(m.content);
if (!res)
return;
const params = res[3].split(" ");
let year = 0;
let search = "";
let mode: ModeDivision | undefined = undefined;
for (const param of params) {
if (/^20[0-9]{2}$/.test(param))
year = parseInt(param, 10);
if (year !== 0) {
search = params.filter(p => p !== param).join(" ");
break;
}
}
if (year === 0) {
year = (new Date).getUTCFullYear();
search = params.join(" ");
}
for (const param of params) {
if (modeRegex.test(param)) {
switch (modeRegex.exec(param)![1]) {
case "standard" || "std": {
mode = await ModeDivision.findOne(1);
break;
} case "taiko" || "tko": {
mode = await ModeDivision.findOne(2);
break;
} case "catch" || "ctb": {
mode = await ModeDivision.findOne(3);
break;
} case "mania" || "man": {
mode = await ModeDivision.findOne(4);
break;
} case "storyboard" || "sb": {
mode = await ModeDivision.findOne(5);
break;
}
}
if (mode) {
search = params.filter(p => p !== param).join(" ");
break;
}
}
}
if (!mode)
mode = await ModeDivision.findOne(1);
const mca = await MCA.findOne({
results: MoreThanOrEqual(new Date()),
nomination: {
start: LessThanOrEqual(new Date()),
},
});
if (year < (mca ? mca.year : (new Date()).getUTCFullYear())) {
await m.reply(`You cannot remove mapping influences for previous years!`);
return;
}
// Find user
let q = search;
let apiUser: APIUser;
if (profileRegex.test(search)) { // Profile linked
const res = profileRegex.exec(m.content);
if (!res)
return;
q = res[3];
apiUser = (await osuClient.user.get(res[3])) as APIUser;
} else
apiUser = (await osuClient.user.get(search)) as APIUser;
if (!apiUser) {
await m.reply(`No user found for **${q}**`);
return;
}
const influenceUser = await User.findOne({
osu: {
userID: apiUser.userId.toString(),
},
});
if (!influenceUser) {
await m.reply(`**${apiUser.username}** doesn't even exist in the Corsace database! You're capping!!!!!!!`);
return;
}
const influence = await Influence.findOne({
user,
influence: influenceUser,
year,
mode,
});
if (!influence) {
await m.reply(`**${influenceUser.osu.username}** influencing you as a mapper for **${year}** in **${mode!.name}** doesn't seem to exist currently!`);
return;
}
await influence.remove();
m.reply(`**${influenceUser.osu.username}** influencing you as a mapper for **${year}** in **${mode!.name}** has been removed!`);
return;
}