35 | {Array(repeat)
36 | .fill(0)
37 | .map((_, i) => (
38 |
47 | {children}
48 |
49 | ))}
50 |
51 | );
52 | }
53 |
--------------------------------------------------------------------------------
/services/backend/functions/background_checks/main.go:
--------------------------------------------------------------------------------
1 | package background_checks
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/JustLABv1/justflow/services/backend/pkg/telemetry"
7 | "github.com/uptrace/bun"
8 | )
9 |
10 | func Init(db *bun.DB) {
11 | ticker := time.NewTicker(1 * time.Minute)
12 | ticker2 := time.NewTicker(10 * time.Second)
13 | quit := make(chan struct{})
14 |
15 | go func() {
16 | for {
17 | select {
18 | case <-ticker.C:
19 | runCheck("checkHangingExecutions", func() { checkHangingExecutions(db) })
20 | runCheck("checkHangingExecutionSteps", func() { checkHangingExecutionSteps(db) })
21 | runCheck("checkDisconnectedAutoRunners", func() { checkDisconnectedAutoRunners(db) })
22 | runCheck("checkForFlowActionUpdates", func() { checkForFlowActionUpdates(db) })
23 | runCheck("scheduleFlowExecutions", func() { scheduleFlowExecutions(db) })
24 | case <-quit:
25 | ticker.Stop()
26 | return
27 | }
28 | }
29 | }()
30 |
31 | go func() {
32 | for {
33 | select {
34 | case <-ticker2.C:
35 | runCheck("checkScheduledExecutions", func() { checkScheduledExecutions(db) })
36 | case <-quit:
37 | ticker2.Stop()
38 | return
39 | }
40 | }
41 | }()
42 | }
43 |
44 | func runCheck(name string, check func()) {
45 | start := time.Now()
46 | check()
47 | duration := time.Since(start).Seconds()
48 | telemetry.BackgroundCheckDurationSeconds.WithLabelValues(name).Observe(duration)
49 | }
50 |
--------------------------------------------------------------------------------
/services/backend/handlers/admins/get_settings.go:
--------------------------------------------------------------------------------
1 | package admins
2 |
3 | import (
4 | "net/http"
5 |
6 | "github.com/JustLABv1/justflow/services/backend/functions/httperror"
7 | functions_runner "github.com/JustLABv1/justflow/services/backend/functions/runner"
8 | "github.com/JustLABv1/justflow/services/backend/pkg/models"
9 |
10 | "github.com/gin-gonic/gin"
11 | "github.com/uptrace/bun"
12 | )
13 |
14 | func GetSettings(context *gin.Context, db *bun.DB) {
15 | var settings models.Settings
16 | err := db.NewSelect().Model(&settings).Where("id = 1").Scan(context)
17 | if err != nil {
18 | httperror.InternalServerError(context, "Error collecting settings data on db", err)
19 | return
20 | }
21 |
22 | // regenerate JustFlowRunnerAutoJoinToken if it got deleted or is not existing
23 | if settings.SharedRunnerAutoJoinToken == "" {
24 | settings.SharedRunnerAutoJoinToken, err = functions_runner.GenerateJustFlowAutoJoinToken(db)
25 | if err != nil {
26 | httperror.InternalServerError(context, "Error generating JustFlowRunnerAutoJoinToken", err)
27 | return
28 | }
29 | _, err = db.NewUpdate().Model(&settings).Set("shared_runner_auto_join_token = ?", settings.SharedRunnerAutoJoinToken).Where("id = 1").Exec(context)
30 | if err != nil {
31 | httperror.InternalServerError(context, "Error updating JustFlowRunnerAutoJoinToken on db", err)
32 | return
33 | }
34 | }
35 |
36 | context.JSON(http.StatusOK, gin.H{"settings": settings})
37 | }
38 |
--------------------------------------------------------------------------------
/services/frontend/lib/fetch/user/stats.ts:
--------------------------------------------------------------------------------
1 | "use server";
2 |
3 | import { cookies } from "next/headers";
4 |
5 | import { serverFetch } from "../serverFetch";
6 |
7 | type Stats = {
8 | stats: object;
9 | };
10 |
11 | type ErrorResponse = {
12 | success: false;
13 | error: string;
14 | message: string;
15 | };
16 |
17 | type SuccessResponse = {
18 | success: true;
19 | data: Stats;
20 | };
21 |
22 | export async function GetUserStats(): Promise