Merge pull request 'Deploy to production' (#101) from staging into production

Reviewed-on: #101
This commit is contained in:
zelda 2025-12-03 12:53:52 +11:00
commit 18701df5ad
11 changed files with 61 additions and 27 deletions

View File

@ -41,9 +41,10 @@ export const updateWebBid = async (bid: Partial<IWebBid>) => {
password, password,
username, username,
origin_url, origin_url,
display_name,
active, active,
arrival_offset_seconds, arrival_offset_seconds,
early_tracking_seconds early_tracking_seconds,
} = removeFalsyValues(bid, ["active"]); } = removeFalsyValues(bid, ["active"]);
try { try {
@ -58,7 +59,8 @@ export const updateWebBid = async (bid: Partial<IWebBid>) => {
origin_url, origin_url,
active, active,
arrival_offset_seconds, arrival_offset_seconds,
early_tracking_seconds early_tracking_seconds,
display_name: display_name || null,
}, },
}); });

View File

@ -21,6 +21,7 @@ export interface IWebBidModelProps extends ModalProps {
const schema = z.object({ const schema = z.object({
username: z.string().min(1, { message: "Username is required" }), username: z.string().min(1, { message: "Username is required" }),
display_name: z.string({ message: "Display name is" }).optional(),
password: z password: z
.string() .string()
.min(6, { message: "Password must be at least 6 characters long" }), .min(6, { message: "Password must be at least 6 characters long" }),
@ -118,6 +119,14 @@ export default function WebAccountModal({
label="Username" label="Username"
{...form.getInputProps("username")} {...form.getInputProps("username")}
/> />
<TextInput
className="col-span-2"
size="sm"
label="Display name"
{...form.getInputProps("display_name")}
/>
<PasswordInput <PasswordInput
withAsterisk withAsterisk
className="col-span-2" className="col-span-2"

View File

@ -55,6 +55,7 @@ export interface IWebBid extends ITimestamp {
origin_url: string; origin_url: string;
url: string | null; url: string | null;
username: string | null; username: string | null;
display_name: string | null;
password: string | null; password: string | null;
active: boolean; active: boolean;
arrival_offset_seconds: number; arrival_offset_seconds: number;

View File

@ -1 +1 @@
{"createdAt":1752455341798} {"createdAt":1764726107601}

View File

@ -1,4 +1,11 @@
import { IsBoolean, IsNumber, IsOptional, IsString, IsUrl, Min } from 'class-validator'; import {
IsBoolean,
IsNumber,
IsOptional,
IsString,
IsUrl,
Min,
} from 'class-validator';
export class UpdateWebBidDto { export class UpdateWebBidDto {
@IsUrl() @IsUrl()
@ -13,7 +20,7 @@ export class UpdateWebBidDto {
@Min(60) @Min(60)
@IsOptional() @IsOptional()
arrival_offset_seconds: number; arrival_offset_seconds: number;
@IsNumber() @IsNumber()
@Min(600) @Min(600)
@IsOptional() @IsOptional()
@ -23,6 +30,10 @@ export class UpdateWebBidDto {
@IsOptional() @IsOptional()
username: string; username: string;
@IsString()
@IsOptional()
display_name: string;
@IsString() @IsString()
@IsOptional() @IsOptional()
password: string; password: string;

View File

@ -24,6 +24,9 @@ export class WebBid extends Timestamp {
@Column({ default: null, nullable: true }) @Column({ default: null, nullable: true })
username: string; username: string;
@Column({ default: null, nullable: true })
display_name: string;
@Column({ default: 300 }) @Column({ default: 300 })
arrival_offset_seconds: number; arrival_offset_seconds: number;

View File

@ -1,17 +1,10 @@
import { shouldResetTool } from '@/ultils';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule'; import { Cron, CronExpression } from '@nestjs/schedule';
import { IsNull, Not } from 'typeorm';
import { BidsService } from './bids.service';
import * as moment from 'moment'; import * as moment from 'moment';
import { import { BidsService } from './bids.service';
isTimeReached,
shouldResetTool,
subtractMinutes,
subtractSeconds,
} from '@/ultils';
import { ConfigsService } from './configs.service'; import { ConfigsService } from './configs.service';
import { DashboardService } from './dashboard.service'; import { DashboardService } from './dashboard.service';
import { Bid } from '../entities/bid.entity';
@Injectable() @Injectable()
export class TasksService { export class TasksService {
private readonly logger = new Logger(TasksService.name); private readonly logger = new Logger(TasksService.name);

View File

@ -1,17 +1,14 @@
import _ from "lodash"; import _ from "lodash";
import { outBid, pushPrice, updateBid } from "../../system/apis/bid.js"; import { outBid, pushPrice, updateBid } from "../../system/apis/bid.js";
import { sendMessage } from "../../system/apis/notification.js"; import axios from "../../system/axios.js";
import { createOutBidLog } from "../../system/apis/out-bid-log.js";
import configs from "../../system/config.js"; import configs from "../../system/config.js";
import CONSTANTS from "../../system/constants.js"; import CONSTANTS from "../../system/constants.js";
import { import {
convertAETtoUTC,
isTimeReached, isTimeReached,
removeFalsyValues, removeFalsyValues,
takeSnapshot, takeSnapshot,
} from "../../system/utils.js"; } from "../../system/utils.js";
import { ProductBid } from "../product-bid.js"; import { ProductBid } from "../product-bid.js";
import axios from "../../system/axios.js";
export class AllbidsProductBid extends ProductBid { export class AllbidsProductBid extends ProductBid {
constructor({ ...prev }) { constructor({ ...prev }) {
@ -208,6 +205,8 @@ export class AllbidsProductBid extends ProductBid {
const historiesData = await this.getHistoriesData(); const historiesData = await this.getHistoriesData();
console.log({ historiesData });
// 📌 Nếu không có dữ liệu trả về thì dừng // 📌 Nếu không có dữ liệu trả về thì dừng
if (!result) { if (!result) {
console.log(`⚠️ [${this.id}] No valid data received, skipping update.`); console.log(`⚠️ [${this.id}] No valid data received, skipping update.`);
@ -226,9 +225,11 @@ export class AllbidsProductBid extends ProductBid {
: null, : null,
// close_time: close_time && !this.close_time ? String(close_time) : null, // test // close_time: close_time && !this.close_time ? String(close_time) : null, // test
name: result?.aucTitle || null, name: result?.aucTitle || null,
metadata: { metadata: isTimeReached(new Date(result.aucCloseUtc).toUTCString())
competor_histories: historiesData, ? null
}, : {
competor_histories: historiesData,
},
}, },
["close_time"] ["close_time"]
); );
@ -240,6 +241,22 @@ export class AllbidsProductBid extends ProductBid {
console.log("✅ Update successful!"); console.log("✅ Update successful!");
const currentHigherBid = historiesData[0];
if (
!isTimeReached(new Date(result.aucCloseUtc).toUTCString()) &&
currentHigherBid?.userName !== this?.web_bid?.display_name &&
this?.web_bid?.display_name &&
currentHigherBid?.amount === this.histories[0].price &&
currentHigherBid?.amount >= this.max_price
) {
console.log(
`⚠️ [${this.id}] ${currentHigherBid?.userName} is highter price`
);
outBid(this.id);
}
return { ...response, name: data.name, close_time: data.close_time }; return { ...response, name: data.name, close_time: data.close_time };
}; };

View File

@ -1,15 +1,13 @@
import path from "path"; import fs from "fs";
import { createOutBidLog } from "../../system/apis/out-bid-log.js"; import { createOutBidLog } from "../../system/apis/out-bid-log.js";
import configs from "../../system/config.js"; import configs from "../../system/config.js";
import { import {
delay, delay,
extractNumber, extractNumber,
getPathProfile, getPathProfile,
isTimeReached,
safeClosePage, safeClosePage,
} from "../../system/utils.js"; } from "../../system/utils.js";
import { ApiBid } from "../api-bid.js"; import { ApiBid } from "../api-bid.js";
import fs from "fs";
export class GrayApiBid extends ApiBid { export class GrayApiBid extends ApiBid {
retry_login = 0; retry_login = 0;

View File

@ -490,8 +490,10 @@ export class GraysProductBid extends ProductBid {
// A.V - Lidcombe NSW // A.V - Lidcombe NSW
const data = bids.find( const data = bids.find(
(bid) => (bid) =>
`${bid?.UserInitials} - ${bid.UserShortAddress}` == "A.V - Lidcombe NSW" `${bid?.UserInitials} - ${bid.UserShortAddress}` ==
(this.web_bid?.display_name || "A.V - Lidcombe NSW")
); );
return data; return data;
} }

View File

@ -1,13 +1,11 @@
import _ from "lodash"; import _ from "lodash";
import { outBid, pushPrice, updateBid } from "../../system/apis/bid.js"; import { outBid, pushPrice, updateBid } from "../../system/apis/bid.js";
import { sendMessage } from "../../system/apis/notification.js";
import { createOutBidLog } from "../../system/apis/out-bid-log.js"; import { createOutBidLog } from "../../system/apis/out-bid-log.js";
import configs from "../../system/config.js"; import configs from "../../system/config.js";
import CONSTANTS from "../../system/constants.js"; import CONSTANTS from "../../system/constants.js";
import { import {
convertAETtoUTC, convertAETtoUTC,
isTimeReached, isTimeReached,
randomDelayWithMeta,
removeFalsyValues, removeFalsyValues,
takeSnapshot, takeSnapshot,
} from "../../system/utils.js"; } from "../../system/utils.js";