fix: setting entities to done
This commit is contained in:
@ -40,6 +40,19 @@ func (p *ImageProcessor) setImageToProcess(ctx context.Context, image model.Imag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ImageProcessor) setImageToDone(ctx context.Context, image model.Image) {
|
||||||
|
err := p.imageModel.UpdateProcess(ctx, image.ID, model.Progress_Complete)
|
||||||
|
if err != nil {
|
||||||
|
// TODO: what can we actually do here for the errors?
|
||||||
|
// We can't stop the work for the others
|
||||||
|
|
||||||
|
p.logger.Error("failed to update image", "err", err)
|
||||||
|
|
||||||
|
// TODO: we can use context here to actually pass some information through
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ImageProcessor) describe(ctx context.Context, image model.Image) {
|
func (p *ImageProcessor) describe(ctx context.Context, image model.Image) {
|
||||||
descriptionSubLogger := p.logger.With("describe image", image.ID)
|
descriptionSubLogger := p.logger.With("describe image", image.ID)
|
||||||
|
|
||||||
@ -97,6 +110,8 @@ func (p *ImageProcessor) processImage(image model.Image) {
|
|||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
p.setImageToDone(ctx, image)
|
||||||
|
|
||||||
// TODO: there is some repeated code here. The ergonomicts of the notifications,
|
// TODO: there is some repeated code here. The ergonomicts of the notifications,
|
||||||
// isn't the best.
|
// isn't the best.
|
||||||
imageNotification = notifications.GetImageNotification(notifications.ImageNotification{
|
imageNotification = notifications.GetImageNotification(notifications.ImageNotification{
|
||||||
|
@ -45,6 +45,19 @@ func (p *StackProcessor) setStackToProcess(ctx context.Context, stack model.Stac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *StackProcessor) setStackToDone(ctx context.Context, stack model.Stacks) {
|
||||||
|
err := p.stackModel.UpdateProcess(ctx, stack.ID, model.Progress_Complete)
|
||||||
|
if err != nil {
|
||||||
|
// TODO: what can we actually do here for the errors?
|
||||||
|
// We can't stop the work for the others
|
||||||
|
|
||||||
|
p.logger.Error("failed to update stack", "err", err)
|
||||||
|
|
||||||
|
// TODO: we can use context here to actually pass some information through
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *StackProcessor) extractInfo(ctx context.Context, stack model.Stacks) {
|
func (p *StackProcessor) extractInfo(ctx context.Context, stack model.Stacks) {
|
||||||
err := p.stackAgent.CreateList(p.logger, stack.UserID, stack.ID, stack.Name, stack.Description)
|
err := p.stackAgent.CreateList(p.logger, stack.UserID, stack.ID, stack.Name, stack.Description)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -87,6 +100,8 @@ func (p *StackProcessor) processImage(stack model.Stacks) {
|
|||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
p.setStackToDone(ctx, stack)
|
||||||
|
|
||||||
// TODO: there is some repeated code here. The ergonomicts of the notifications,
|
// TODO: there is some repeated code here. The ergonomicts of the notifications,
|
||||||
// isn't the best.
|
// isn't the best.
|
||||||
stackNotification = notifications.GetStackNotification(notifications.StackNotification{
|
stackNotification = notifications.GetStackNotification(notifications.StackNotification{
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
deleteImage,
|
deleteImage,
|
||||||
deleteImageFromStack,
|
deleteImageFromStack,
|
||||||
|
deleteStack,
|
||||||
deleteStackItem,
|
deleteStackItem,
|
||||||
getUserImages,
|
getUserImages,
|
||||||
JustTheImageWhatAreTheseNames,
|
JustTheImageWhatAreTheseNames,
|
||||||
@ -25,8 +26,11 @@ export type SearchImageStore = {
|
|||||||
userImages: Accessor<JustTheImageWhatAreTheseNames>;
|
userImages: Accessor<JustTheImageWhatAreTheseNames>;
|
||||||
|
|
||||||
onRefetchImages: () => void;
|
onRefetchImages: () => void;
|
||||||
|
|
||||||
onDeleteImage: (imageID: string) => void;
|
onDeleteImage: (imageID: string) => void;
|
||||||
onDeleteImageFromStack: (stackID: string, imageID: string) => void;
|
onDeleteImageFromStack: (stackID: string, imageID: string) => void;
|
||||||
|
|
||||||
|
onDeleteStack: (stackID: string) => void;
|
||||||
onDeleteStackItem: (stackID: string, schemaItemID: string) => void;
|
onDeleteStackItem: (stackID: string, schemaItemID: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,6 +80,9 @@ export const SearchImageContextProvider: Component<ParentProps> = (props) => {
|
|||||||
onDeleteImageFromStack: (stackID: string, imageID: string) => {
|
onDeleteImageFromStack: (stackID: string, imageID: string) => {
|
||||||
deleteImageFromStack(stackID, imageID).then(refetch);
|
deleteImageFromStack(stackID, imageID).then(refetch);
|
||||||
},
|
},
|
||||||
|
onDeleteStack: (stackID: string) => {
|
||||||
|
deleteStack(stackID).then(refetch)
|
||||||
|
},
|
||||||
onDeleteStackItem: (stackID: string, schemaItemID: string) => {
|
onDeleteStackItem: (stackID: string, schemaItemID: string) => {
|
||||||
deleteStackItem(stackID, schemaItemID).then(refetch);
|
deleteStackItem(stackID, schemaItemID).then(refetch);
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
createResource,
|
createResource,
|
||||||
createSignal,
|
createSignal,
|
||||||
} from "solid-js";
|
} from "solid-js";
|
||||||
import { base, deleteStack, getAccessToken } from "../../network";
|
import { base, getAccessToken } from "../../network";
|
||||||
import { Dialog } from "@kobalte/core";
|
import { Dialog } from "@kobalte/core";
|
||||||
|
|
||||||
const DeleteButton: Component<{ onDelete: () => void }> = (props) => {
|
const DeleteButton: Component<{ onDelete: () => void }> = (props) => {
|
||||||
@ -107,14 +107,14 @@ export const Stack: Component = () => {
|
|||||||
const { stackID } = useParams();
|
const { stackID } = useParams();
|
||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
|
|
||||||
const { stacks, onDeleteImageFromStack } = useSearchImageContext();
|
const { stacks, onDeleteImageFromStack, onDeleteStack } = useSearchImageContext();
|
||||||
|
|
||||||
const [accessToken] = createResource(getAccessToken);
|
const [accessToken] = createResource(getAccessToken);
|
||||||
|
|
||||||
const stack = () => stacks().find((l) => l.ID === stackID);
|
const stack = () => stacks().find((l) => l.ID === stackID);
|
||||||
|
|
||||||
const handleDeleteStack = async () => {
|
const handleDeleteStack = async () => {
|
||||||
await deleteStack(stackID)
|
onDeleteStack(stackID);
|
||||||
nav("/");
|
nav("/");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user