Merged PR 649: Revert "手動実行できるように変更"
Revert "手動実行できるように変更" Reverted commit `57fc7a17`.
This commit is contained in:
parent
57fc7a17b5
commit
60bb8f9e20
@ -1,12 +1,4 @@
|
||||
import {
|
||||
app,
|
||||
InvocationContext,
|
||||
Timer,
|
||||
HttpRequest,
|
||||
HttpHandler,
|
||||
HttpResponseInit,
|
||||
HttpResponse,
|
||||
} from "@azure/functions";
|
||||
import { app, InvocationContext, Timer } from "@azure/functions";
|
||||
import { Between, DataSource, In, MoreThan, Repository } from "typeorm";
|
||||
import { User } from "../entity/user.entity";
|
||||
import { Account } from "../entity/account.entity";
|
||||
@ -28,15 +20,14 @@ import {
|
||||
|
||||
export async function licenseAutoAllocationProcessing(
|
||||
context: InvocationContext,
|
||||
datasource: DataSource,
|
||||
dateToTrigger?: Date
|
||||
datasource: DataSource
|
||||
): Promise<void> {
|
||||
try {
|
||||
context.log("[IN]licenseAutoAllocationProcessing");
|
||||
|
||||
// ライセンスの有効期間判定用
|
||||
const currentDateZeroTime = new DateWithZeroTime(dateToTrigger);
|
||||
const currentDateEndTime = new DateWithDayEndTime(dateToTrigger);
|
||||
const currentDateZeroTime = new DateWithZeroTime();
|
||||
const currentDateEndTime = new DateWithDayEndTime();
|
||||
|
||||
// 自動更新対象の候補となるアカウントを取得
|
||||
const accountRepository = datasource.getRepository(Account);
|
||||
@ -387,69 +378,3 @@ class autoAllocationList {
|
||||
accountId: number;
|
||||
userIds: number[];
|
||||
}
|
||||
|
||||
const httpTrigger: HttpHandler = async function (
|
||||
req: HttpRequest,
|
||||
context: InvocationContext
|
||||
): Promise<HttpResponseInit | HttpResponse> {
|
||||
try {
|
||||
if (req.method === "GET") {
|
||||
const queryParams = new URLSearchParams(req.url.split("?")[1]); // クエリパラメータを取得
|
||||
|
||||
const requestedDate = queryParams.get("date");
|
||||
|
||||
let dateToTrigger: Date;
|
||||
if (requestedDate) {
|
||||
dateToTrigger = new Date(requestedDate);
|
||||
} else {
|
||||
dateToTrigger = new Date();
|
||||
}
|
||||
context.log("[IN]licenseAutoAllocation");
|
||||
dotenv.config({ path: ".env" });
|
||||
dotenv.config({ path: ".env.local", override: true });
|
||||
let datasource: DataSource;
|
||||
try {
|
||||
datasource = new DataSource({
|
||||
type: "mysql",
|
||||
host: process.env.DB_HOST,
|
||||
port: Number(process.env.DB_PORT),
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
entities: [User, Account, License, LicenseAllocationHistory],
|
||||
});
|
||||
await datasource.initialize();
|
||||
} catch (e) {
|
||||
context.log("database initialize failed.");
|
||||
context.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
await licenseAutoAllocationProcessing(context, datasource, dateToTrigger);
|
||||
context.log("Automatic license allocation has been triggered.");
|
||||
return {
|
||||
status: 200,
|
||||
body: "Automatic license allocation has been triggered.",
|
||||
};
|
||||
} else {
|
||||
context.log("Please use the GET method.");
|
||||
return {
|
||||
status: 400,
|
||||
body: "Please use the GET method.",
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
context.log("licenseAutoAllocation failed.");
|
||||
context.error(e);
|
||||
return {
|
||||
status: 500,
|
||||
body: "licenseAutoAllocation failed.",
|
||||
};
|
||||
} finally {
|
||||
context.log("[OUT]licenseAutoAllocation");
|
||||
}
|
||||
};
|
||||
|
||||
export default httpTrigger;
|
||||
|
||||
app.get("/licenseAutoAllocation", httpTrigger);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user