Skip to content

Commit

Permalink
refactor: Enable lazy loading for images in Copilot/Utils/CopilotActi…
Browse files Browse the repository at this point in the history
…on.ts, Common/Utils/CronTime.ts, Common/Server/Services/BillingInvoiceService.ts, and Dashboard/src/Pages/Settings/Invoices.tsx
  • Loading branch information
simlarsen committed Sep 5, 2024
1 parent 1682a25 commit e3c68fd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
3 changes: 3 additions & 0 deletions App/FeatureSet/Workers/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ import logger from "Common/Server/Utils/Logger";
import "./Jobs/Probe/SendOwnerAddedNotification";
import "./Jobs/Probe/UpdateConnectionStatus";

// Copilot Actions.
import "./Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime";

// Telemetry Monitors.
import "./Jobs/TelemetryMonitor/MonitorTelemetryMonitor";
import Express, { ExpressApplication } from "Common/Server/Utils/Express";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RunCron(
await CopilotActionService.findBy({
query: {
copilotActionStatus: CopilotActionStatus.PROCESSING,
statusChangedAt: QueryHelper.lessThanEqualTo(lastHour),
statusChangedAt: QueryHelper.lessThanEqualToOrNull(lastHour),
},
select: {
_id: true,
Expand Down
2 changes: 0 additions & 2 deletions Copilot/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ let currentFixCount: number = 1;
const init: PromiseVoidFunction = async (): Promise<void> => {
// check if copilot is disabled.

debugger;

if (GetIsCopilotDisabled()) {
logger.info("Copilot is disabled. Exiting.");
ProcessUtil.haltProcessWithSuccess();
Expand Down
41 changes: 36 additions & 5 deletions Copilot/Service/CopilotActions/ImproveComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ServiceRepositoryUtil from "../../Utils/ServiceRepository";
import Dictionary from "Common/Types/Dictionary";
import ArrayUtil from "Common/Utils/Array";
import CopilotActionProp from "Common/Types/Copilot/CopilotActionProps/Index";
import BadDataException from "Common/Types/Exception/BadDataException";

export default class ImproveComments extends CopilotActionBase {
public isRequirementsMet: boolean = false;
Expand Down Expand Up @@ -54,9 +55,6 @@ export default class ImproveComments extends CopilotActionBase {
maxActionsToQueue: number;
}): Promise<Array<CopilotActionProp>> {
// get files in the repo.

debugger;

logger.debug(
`${this.copilotActionType} - Getting files to queue for improve comments.`,
);
Expand Down Expand Up @@ -113,17 +111,50 @@ export default class ImproveComments extends CopilotActionBase {
return actionsPropsQueued;
}

public override async getCommitMessage(
data: CopilotProcess,
): Promise<string> {
return (
"Improved comments on " + (data.actionProp as FileActionProp).filePath
);
}

public override async getPullRequestTitle(
data: CopilotProcess,
): Promise<string> {
return (
"Improved comments on " + (data.actionProp as FileActionProp).filePath
);
}

public override async getPullRequestBody(
data: CopilotProcess,
): Promise<string> {
return `Improved comments on ${(data.actionProp as FileActionProp).filePath}
${await this.getDefaultPullRequestBody()}
`;
}

public override isActionComplete(_data: CopilotProcess): Promise<boolean> {
return Promise.resolve(this.isRequirementsMet);
}

public override async onExecutionStep(
data: CopilotProcess,
): Promise<CopilotProcess> {
// Action Prompt
const filePath: string = (data.actionProp as FileActionProp).filePath;

if (!filePath) {
throw new BadDataException("File Path is not set in the action prop.");
}

const fileContent: string = await ServiceRepositoryUtil.getFileContent({
filePath: filePath,
});

const codeParts: string[] = await this.splitInputCode({
code: "",
code: fileContent,
itemSize: 500,
});

Expand Down
1 change: 0 additions & 1 deletion Copilot/Service/CopilotActions/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class CopilotActionService {
ActionDictionary[data.copilotAction.copilotActionType!];

if (!ActionType) {
debugger;
throw new BadDataException("Invalid CopilotActionType");
}

Expand Down
2 changes: 0 additions & 2 deletions Copilot/Utils/CopilotAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ export default class CopilotActionUtil {
throw new BadDataException("Repository Secret Key is required");
}

debugger;

const url: URL = URL.fromString(
GetOneUptimeURL().toString() + "/api",
).addRoute(
Expand Down

0 comments on commit e3c68fd

Please sign in to comment.