Skip to content

Commit

Permalink
fix(cdn,ui): display last log line and fix job variables modal (#5959)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored Sep 30, 2021
1 parent 75bec78 commit 2997297
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 64 deletions.
25 changes: 18 additions & 7 deletions engine/cdn/redis/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,34 @@ type Reader struct {
}

func (r *Reader) get(from uint, to uint) ([]Line, error) {
res, err := r.Store.ScoredSetScanWithScores(context.Background(), cache.Key(r.PrefixKey, r.ItemID), float64(from), float64(to))
// Adding +1 to given "to" value to match last line with since > 0
res, err := r.Store.ScoredSetScanWithScores(context.Background(), cache.Key(r.PrefixKey, r.ItemID), float64(from), float64(to+1))
if err != nil {
return nil, err
}
ls := make([]Line, len(res))

ls := make([]Line, 0, len(res))
for i := range res {
var l Line
scoreD := decimal.NewFromFloat(res[i].Score)
ls[i].Number = scoreD.IntPart()
floatD := scoreD.Sub(decimal.NewFromInt(ls[i].Number))
ls[i].Since = floatD.Coefficient().Int64()
l.Number = scoreD.IntPart()

// Filter lines to prevent the line with number=to+1 to be returned
if l.Number > int64(to) {
continue
}

floatD := scoreD.Sub(decimal.NewFromInt(l.Number))
l.Since = floatD.Coefficient().Int64()

var value string
if err := sdk.JSONUnmarshal(res[i].Value, &value); err != nil {
return nil, sdk.WrapError(err, "cannot unmarshal line value from store")
}
ls[i].Value = strings.TrimFunc(value, unicode.IsNumber)
ls[i].Value = strings.TrimPrefix(ls[i].Value, "#")
l.Value = strings.TrimFunc(value, unicode.IsNumber)
l.Value = strings.TrimPrefix(l.Value, "#")

ls = append(ls, l)
}
return ls, nil
}
Expand Down
113 changes: 58 additions & 55 deletions ui/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SelectFilterComponent } from 'app/shared/select/select.component';
import { WorkflowHookMenuEditComponent } from 'app/shared/workflow/menu/edit-hook/menu.edit.hook.component';
import { WorkflowWizardNodeConditionComponent } from 'app/shared/workflow/wizard/conditions/wizard.conditions.component';
import { WorkflowWizardOutgoingHookComponent } from 'app/shared/workflow/wizard/outgoinghook/wizard.outgoinghook.component';
import { WorkflowRunJobVariableComponent } from 'app/views/workflow/run/node/pipeline/variables/job.variables.component';
import { WorkflowRunJobComponent } from 'app/views/workflow/run/node/pipeline/workflow-run-job/workflow-run-job.component';
import { NgSemanticModule } from 'ng-semantic/ng-semantic';
import { CodemirrorModule } from 'ng2-codemirror-typescript/Codemirror';
Expand Down Expand Up @@ -136,7 +137,10 @@ import { ZoneComponent } from './zone/zone.component';
ActionComponent,
ActionStepComponent,
ActionStepFormComponent,
AnsiPipe,
AsCodeEventComponent,
AsCodeSaveFormComponent,
AsCodeSaveModalComponent,
AuditListComponent,
AutoFocusInputComponent,
BreadcrumbComponent,
Expand All @@ -148,12 +152,11 @@ import { ZoneComponent } from './zone/zone.component';
ConfirmModalComponent,
CutPipe,
DataTableComponent,
DurationMsPipe,
PaginationComponent,
DeleteButtonComponent,
DeleteModalComponent,
DiffItemComponent,
DiffListComponent,
DurationMsPipe,
FavoriteCardsComponent,
ForMapPipe,
GroupFormComponent,
Expand All @@ -163,26 +166,25 @@ import { ZoneComponent } from './zone/zone.component';
LabelsEditComponent,
MenuComponent,
NgForNumber,
PaginationComponent,
ParameterFormComponent,
ParameterListComponent,
ParameterValueComponent,
PermissionFormComponent,
PermissionListComponent,
ProjectBreadcrumbComponent,
RepoManagerFormComponent,
RequirementsFormComponent,
RequirementsListComponent,
RepoManagerFormComponent,
SafeHtmlPipe,
AnsiPipe,
ScrollviewComponent,
SelectFilterComponent,
SelectorPipe,
SelectPipe,
ScrollviewComponent,
StatusIconComponent,
TabsComponent,
ToastHTTPErrorComponent,
TruncatePipe,
AsCodeSaveModalComponent,
AsCodeSaveFormComponent,
UploadButtonComponent,
UsageApplicationsComponent,
UsageComponent,
Expand All @@ -207,6 +209,8 @@ import { ZoneComponent } from './zone/zone.component';
WorkflowNodeHookDetailsComponent,
WorkflowNodeHookFormComponent,
WorkflowNodeRunParamComponent,
WorkflowRunJobComponent,
WorkflowRunJobVariableComponent,
WorkflowSidebarRunListComponent,
WorkflowTemplateApplyFormComponent,
WorkflowTemplateApplyModalComponent,
Expand All @@ -223,10 +227,8 @@ import { ZoneComponent } from './zone/zone.component';
WorkflowWNodeMenuEditComponent,
WorkflowWNodeOutGoingHookComponent,
WorkflowWNodePipelineComponent,
WorkflowRunJobComponent,
ZoneComponent,
ZoneContentComponent,
ToastHTTPErrorComponent
ZoneContentComponent
],
entryComponents: [
NguiAutoCompleteComponent,
Expand All @@ -245,99 +247,100 @@ import { ZoneComponent } from './zone/zone.component';
],
exports: [
ActionComponent,
AuditListComponent,
ActionStepComponent,
ActionStepFormComponent,
AnsiPipe,
AsCodeEventComponent,
AsCodeSaveFormComponent,
AsCodeSaveModalComponent,
AuditListComponent,
AutoFocusInputComponent,
BreadcrumbComponent,
ProjectBreadcrumbComponent,
CallbackPipe,
ChartComponentComponent,
ClipboardModule,
CodemirrorModule,
CommitListComponent,
CommonModule,
ClipboardModule,
ConditionsComponent,
ConfirmButtonComponent,
ConfirmModalComponent,
CutPipe,
GroupFormComponent,
DataTableComponent,
DeleteButtonComponent,
DurationMsPipe,
ConfirmButtonComponent,
UploadButtonComponent,
DeleteModalComponent,
DiffItemComponent,
DiffListComponent,
DragulaModule,
DurationMsPipe,
FavoriteCardsComponent,
ForMapPipe,
FormsModule,
KeysPipe,
GroupFormComponent,
InfiniteScrollModule,
KeysFormComponent,
KeysListComponent,
InfiniteScrollModule,
KeysPipe,
LabelsEditComponent,
MarkdownModule,
MenuComponent,
MomentModule,
NgForNumber,
NgSemanticModule,
NgxAutoScroll,
ConditionsComponent,
ParameterListComponent,
PaginationComponent,
ParameterFormComponent,
ParameterListComponent,
ParameterValueComponent,
PermissionFormComponent,
PermissionListComponent,
ProjectBreadcrumbComponent,
ReactiveFormsModule,
RepoManagerFormComponent,
RequirementsFormComponent,
RequirementsListComponent,
SafeHtmlPipe,
ScrollviewComponent,
SelectorPipe,
SelectPipe,
StatusIconComponent,
SuiModule,
TabsComponent,
ToastHTTPErrorComponent,
TranslateModule,
TruncatePipe,
SafeHtmlPipe,
AnsiPipe,
AsCodeSaveModalComponent,
AsCodeSaveFormComponent,
UploadButtonComponent,
UsageApplicationsComponent,
UsageComponent,
UsageEnvironmentsComponent,
UsagePipelinesComponent,
UsageWorkflowsComponent,
VariableComponent,
VariableFormComponent,
VariableValueComponent,
VCSStrategyComponent,
VulnerabilitiesComponent,
VulnerabilitiesListComponent,
WarningModalComponent,
DeleteModalComponent,
ConfirmModalComponent,
LabelsEditComponent,
WorkflowWNodeComponent,
WorkflowSidebarRunListComponent,
WorkflowWNodeMenuEditComponent,
WorkflowNodeAddWizardComponent,
WorkflowDeleteNodeComponent,
WorkflowNodeRunParamComponent,
WorkflowNodeAddWizardComponent,
WorkflowNodeEditModalComponent,
WorkflowNodeHookComponent,
WorkflowNodeHookDetailsComponent,
WorkflowNodeHookFormComponent,
WorkflowTriggerComponent,
WorkflowNodeEditModalComponent,
WorkflowNodeRunParamComponent,
WorkflowRunJobComponent,
ZoneComponent,
ZoneContentComponent,
UsageWorkflowsComponent,
UsageApplicationsComponent,
UsagePipelinesComponent,
UsageEnvironmentsComponent,
UsageComponent,
DiffItemComponent,
DiffListComponent,
VCSStrategyComponent,
FavoriteCardsComponent,
SelectorPipe,
SelectPipe,
DataTableComponent,
PaginationComponent,
WorkflowRunJobVariableComponent,
WorkflowSidebarRunListComponent,
WorkflowTemplateApplyFormComponent,
WorkflowTemplateApplyModalComponent,
WorkflowTemplateBulkModalComponent,
WorkflowTemplateParamFormComponent,
TabsComponent,
MenuComponent,
ScrollviewComponent,
AutoFocusInputComponent,
ToastHTTPErrorComponent
WorkflowTriggerComponent,
WorkflowWNodeComponent,
WorkflowWNodeMenuEditComponent,
ZoneComponent,
ZoneContentComponent
]
})
export class SharedModule {
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/views/workflow/workflow.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WorkflowGraphComponent } from './graph/workflow.graph.component';
import { WorkflowRunArtifactListComponent } from './run/node/artifact/artifact.list.component';
import { WorkflowNodeRunHistoryComponent } from './run/node/history/history.component';
import { WorkflowRunNodePipelineComponent } from './run/node/pipeline/node.pipeline.component';
import { WorkflowRunJobVariableComponent } from './run/node/pipeline/variables/job.variables.component';
import { WorkflowNodeRunSummaryComponent } from './run/node/summary/run.summary.component';
import { WorkflowRunTestTableComponent } from './run/node/test/table/test.table.component';
import { WorkflowRunTestsResultComponent } from './run/node/test/tests.component';
Expand Down Expand Up @@ -35,7 +34,6 @@ import { workflowRouting } from './workflow.routing';
WorkflowNotificationListComponent,
WorkflowRunArtifactListComponent,
WorkflowRunComponent,
WorkflowRunJobVariableComponent,
WorkflowRunNodePipelineComponent,
WorkflowRunSummaryComponent,
WorkflowRunTestsResultComponent,
Expand Down

0 comments on commit 2997297

Please sign in to comment.