Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Failed or Canceled Export Retry Button #2975

Merged
merged 10 commits into from Feb 17, 2022

Conversation

krishnaglick
Copy link
Contributor

@krishnaglick krishnaglick commented Feb 15, 2022

Change description

Description here

Checklists

Development

  • Application changes have been tested appropriately

Impact

  • Code follows company security practices and guidelines
  • Security impact of change has been considered
  • Performance impact of change has been considered
  • Possible migration needs considered (model migrations, config migrations, etc.)

Please explain any security, performance, migration, or other impacts if relevant:

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached where applicable.
  • Relevant tags have been added to the PR (bug, enhancement, internal, etc.)

@krishnaglick krishnaglick added the enhancement New feature or request label Feb 15, 2022
Copy link
Contributor Author

@krishnaglick krishnaglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2022-02-15 at 4 06 39 PM
The list and the detail view have different ways to trigger the same thing. Could replicate the icon method on the detail view, or try to fit the button on the list.

@@ -175,7 +175,7 @@ export namespace ExportOps {
saveExports = true
) {
const where: WhereOptions<Export> = {
state: "failed",
state: { [Op.in]: ["failed", "canceled"] },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedroslopez This is a change in existing functionality, I'm unsure if it's a problem.
I can move this logic out so retried canceled exports tell it explicitly to run them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this could affect the existing "retry failed" functionality. After #2818, we are now canceling older exports if there are multiple for the same record/destination (test case here). This means that these intentionally canceled ones would also be retried when doing it by date range.

Seeing this and the date range thing makes me think that perhaps this is a different method, ExportOps.retryExportById or similar. To ensure this new one and the existing one are retrying in the same way we could break out the actual updating of the export into a separate function and share that.

@@ -31,15 +31,15 @@ export namespace CLS {
* Wrap an Async function f in such a way that all enqueued afterCommit / enqueueTasks during invocation will be run afterwords
* Returns the return value of function f
*/
export interface CLSWrapMethod {
export interface CLSWrapMethod<T = any> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generics!

public async requestAction<A extends Action>(
verb: Method = "get",
path: string,
data: Partial<ParamsFrom<A>>, // TODO: Make ParamsFrom handle required
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this handles required we can use this to type input params in the Client!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use this to handle type inputs on the client anyway, but it'll be better.

import EnterpriseLink from "../GrouparooLink";
import LoadingTable from "../LoadingTable";
import Pagination from "../Pagination";
import { ExportGroupsDiff, ExportRecordPropertiesDiff } from "./Diff";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted imports, no negative effects seen.

style={{ cursor: "pointer" }}
onClick={() => retryExport(_export, index)}
/>
) : null}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bleonard If you get a chance to look over things, this is what this looks like.
Screen Shot 2022-02-15 at 4 00 18 PM

Retry Export
</LoadingButton>,
]}
>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to Edmundo's managed card 👌

ui/ui-components/components/export/List.tsx Outdated Show resolved Hide resolved
ui/ui-components/utils/apiData.ts Outdated Show resolved Hide resolved
const [_export, setExport] = useState(props._export);
const [loading, setLoading] = useState(false);

const retryExport = useCallback(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this logic seems to be repeated in two files. I wonder if we could encapsulate part, if not all of this logic, maybe in a hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best option may be to extract the meat of the function and just export that. Otherwise you'll end up passing in all the hook setters, etc. I'll move it, lemme know what you think!

ui/ui-components/components/export/List.tsx Outdated Show resolved Hide resolved
@@ -175,7 +175,7 @@ export namespace ExportOps {
saveExports = true
) {
const where: WhereOptions<Export> = {
state: "failed",
state: { [Op.in]: ["failed", "canceled"] },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this could affect the existing "retry failed" functionality. After #2818, we are now canceling older exports if there are multiple for the same record/destination (test case here). This means that these intentionally canceled ones would also be retried when doing it by date range.

Seeing this and the date range thing makes me think that perhaps this is a different method, ExportOps.retryExportById or similar. To ensure this new one and the existing one are retrying in the same way we could break out the actual updating of the export into a separate function and share that.

Krishna Glick added 4 commits February 16, 2022 10:38
@krishnaglick krishnaglick force-pushed the 180997068-failed-or-cancelled-export-retry-button branch from b9d4e0f to c42a06e Compare February 16, 2022 15:39
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

}: {
params: ParamsFrom<ExportsRetryFailedById>;
}) {
console.log(params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log

@@ -314,7 +314,7 @@ export class Export extends CommonModel<Export> {
}
}

static async retryFailed(
static retryFailed(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be async since we're not awaiting anything.

public async requestAction<A extends Action>(
verb: Method = "get",
path: string,
data: Partial<ParamsFrom<A>>, // TODO: Make ParamsFrom handle required
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use this to handle type inputs on the client anyway, but it'll be better.

core/src/config/routes.ts Outdated Show resolved Hide resolved
core/src/modules/ops/export.ts Outdated Show resolved Hide resolved
core/src/modules/ops/export.ts Outdated Show resolved Hide resolved
@edmundito
Copy link
Contributor

@krishnaglick I feel that this PR is now doing too much: Both the feature change and the action cleanup.

@krishnaglick
Copy link
Contributor Author

@krishnaglick I feel that this PR is now doing too much: Both the feature change and the action cleanup.

I can pull it out, but it did catch a bug. This is definitely a larger PR but I'm pretty sure it didn't break anything since it's just a type-inference fix.

Copy link
Member

@pedroslopez pedroslopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one suggestion on keeping the names consistent.

core/src/config/routes.ts Outdated Show resolved Hide resolved
ui/ui-components/client/client.ts Show resolved Hide resolved
ui/ui-components/client/client.ts Outdated Show resolved Hide resolved
@krishnaglick krishnaglick merged commit c07f674 into main Feb 17, 2022
@krishnaglick krishnaglick deleted the 180997068-failed-or-cancelled-export-retry-button branch February 17, 2022 16:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants