ronantakizawa/codereview-bench huggingface dataset:
Repository: go-gitea/gitea
File: routers/api/v1/user/action.go (Go)

Code before:

	ctx.Status(http.StatusNoContent)
}

// CreateVariable create a user-level variable
func CreateVariable(ctx *context.APIContext) {
	// swagger:operation POST /user/actions/variables/{variablename} user createUserVariable
	// ---
	// summary: Create a user-level variable
	// consumes:
	// - application/json
	// produces:
	// - application/json
	// parameters:
	// - name: variablename
	//   in: path
	//   description: name of the variable
	//   type: string
	//   required: true
	// - name: body
	//   in: body
	//   schema:
	//     "$ref": "#/definitions/CreateVariableOption"
	// responses:
	//   "201":
	//     description: response when creating a repo-level variable
	//   "400":
	//     "$ref": "#/responses/error"
	//   "409":
	//     description: variable name already exists.

	opt := web.GetForm(ctx).(*api.CreateVariableOption)

	ownerID := ctx.Doer.ID
	variableName := ctx.PathParam("variablename")

	v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
		OwnerID: ownerID,
		Name:    variableName,
	})
	if err != nil && !errors.Is(err, util.ErrNotExist) {
		ctx.APIErrorInternal(err)
		return
	}
	if v != nil && v.ID > 0 {
		ctx.APIError(http.StatusConflict, util.NewAlreadyExistErrorf("variable name %s already exists", variableName))
		return
	}

	if _, err := actions_service.CreateVariable(ctx, ownerID, 0, variableName, opt.Value, opt.Description); err != nil {
		if errors.Is(err, util.ErrInvalidArgument) {

Review comment (suggestion):
```suggestion
	//     description: successfully created the user-level variable
```

Code after:

	ctx.Status(http.StatusNoContent)
}

// CreateVariable create a user-level variable
func CreateVariable(ctx *context.APIContext) {
	// swagger:operation POST /user/actions/variables/{variablename} user createUserVariable
	// ---
	// summary: Create a user-level variable
	// consumes:
	// - application/json
	// produces:
	// - application/json
	// parameters:
	// - name: variablename
	//   in: path
	//   description: name of the variable
	//   type: string
	//   required: true
	// - name: body
	//   in: body
	//   schema:
	//     "$ref": "#/definitions/CreateVariableOption"
	// responses:
	//   "201":
	//     description: successfully created the user-level variable
	//   "400":
	//     "$ref": "#/responses/error"
	//   "409":
	//     description: variable name already exists.

	opt := web.GetForm(ctx).(*api.CreateVariableOption)

	ownerID := ctx.Doer.ID
	variableName := ctx.PathParam("variablename")

	v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
		OwnerID: ownerID,
		Name:    variableName,
	})
	if err != nil && !errors.Is(err, util.ErrNotExist) {
		ctx.APIErrorInternal(err)
		return
	}
	if v != nil && v.ID > 0 {
		ctx.APIError(http.StatusConflict, util.NewAlreadyExistErrorf("variable name %s already exists", variableName))
		return
	}

	if _, err := actions_service.CreateVariable(ctx, ownerID, 0, variableName, opt.Value, opt.Description); err != nil {
		if errors.Is(err, util.ErrInvalidArgument) {
Repository: go-gitea/gitea
File: routers/web/repo/actions/view.go (Go)

Code before:
}

func ViewWorkflowFile(ctx *context_module.Context) {
	runIndex := getRunIndex(ctx)
	run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
	if err != nil {
		ctx.NotFoundOrServerError("GetRunByIndex", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	commit, err := ctx.Repo.GitRepo.GetCommit(run.CommitSHA)
	if err != nil {
		ctx.NotFoundOrServerError("GetCommit", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	rpath, entries, err := actions.ListWorkflows(commit)
	if err != nil {
		ctx.ServerError("ListWorkflows", err)
		return
	}
	for _, entry := range entries {
		if entry.Name() == run.WorkflowID {
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), url.PathEscape(run.WorkflowID)))
			return
		}
	}
	ctx.NotFound(nil)
}

type LogCursor struct {
	Step     int   `json:"step"`
	Cursor   int64 `json:"cursor"`
	Expanded bool  `json:"expanded"`
}

type ViewRequest struct {
	LogCursors []LogCursor `json:"logCursors"`
}

type ArtifactsViewItem struct {
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	Status string `json:"status"`
}

type ViewResponse struct {
	Artifacts []*ArtifactsViewItem `json:"artifacts"`


Review comment (security):
```suggestion
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), url.PathEscapeSegments(run.WorkflowID)))
```

Code after:
}

func ViewWorkflowFile(ctx *context_module.Context) {
	runIndex := getRunIndex(ctx)
	run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
	if err != nil {
		ctx.NotFoundOrServerError("GetRunByIndex", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	commit, err := ctx.Repo.GitRepo.GetCommit(run.CommitSHA)
	if err != nil {
		ctx.NotFoundOrServerError("GetCommit", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	rpath, entries, err := actions.ListWorkflows(commit)
	if err != nil {
		ctx.ServerError("ListWorkflows", err)
		return
	}
	for _, entry := range entries {
		if entry.Name() == run.WorkflowID {
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), util.PathEscapeSegments(run.WorkflowID)))
			return
		}
	}
	ctx.NotFound(nil)
}

type LogCursor struct {
	Step     int   `json:"step"`
	Cursor   int64 `json:"cursor"`
	Expanded bool  `json:"expanded"`
}

type ViewRequest struct {
	LogCursors []LogCursor `json:"logCursors"`
}

type ArtifactsViewItem struct {
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	Status string `json:"status"`
}

type ViewResponse struct {
	Artifacts []*ArtifactsViewItem `json:"artifacts"`
Repository: go-gitea/gitea
File: routers/web/repo/actions/view.go (Go)

Code before:
}

func ViewWorkflowFile(ctx *context_module.Context) {
	runIndex := getRunIndex(ctx)
	run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
	if err != nil {
		ctx.NotFoundOrServerError("GetRunByIndex", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	commit, err := ctx.Repo.GitRepo.GetCommit(run.CommitSHA)
	if err != nil {
		ctx.NotFoundOrServerError("GetCommit", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	rpath, entries, err := actions.ListWorkflows(commit)
	if err != nil {
		ctx.ServerError("ListWorkflows", err)
		return
	}
	for _, entry := range entries {
		if entry.Name() == run.WorkflowID {
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), url.PathEscapeSegments(run.WorkflowID)))
			return
		}
	}
	ctx.NotFound(nil)
}

type LogCursor struct {
	Step     int   `json:"step"`
	Cursor   int64 `json:"cursor"`
	Expanded bool  `json:"expanded"`
}

type ViewRequest struct {
	LogCursors []LogCursor `json:"logCursors"`
}

type ArtifactsViewItem struct {
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	Status string `json:"status"`
}

type ViewResponse struct {
	Artifacts []*ArtifactsViewItem `json:"artifacts"`


Review comment (security):
```suggestion
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), util.PathEscapeSegments(run.WorkflowID)))
```

Code after:
}

func ViewWorkflowFile(ctx *context_module.Context) {
	runIndex := getRunIndex(ctx)
	run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
	if err != nil {
		ctx.NotFoundOrServerError("GetRunByIndex", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	commit, err := ctx.Repo.GitRepo.GetCommit(run.CommitSHA)
	if err != nil {
		ctx.NotFoundOrServerError("GetCommit", func(err error) bool {
			return errors.Is(err, util.ErrNotExist)
		}, err)
		return
	}
	rpath, entries, err := actions.ListWorkflows(commit)
	if err != nil {
		ctx.ServerError("ListWorkflows", err)
		return
	}
	for _, entry := range entries {
		if entry.Name() == run.WorkflowID {
			ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s", ctx.Repo.RepoLink, url.PathEscape(run.CommitSHA), util.PathEscapeSegments(rpath), util.PathEscapeSegments(run.WorkflowID)))
			return
		}
	}
	ctx.NotFound(nil)
}

type LogCursor struct {
	Step     int   `json:"step"`
	Cursor   int64 `json:"cursor"`
	Expanded bool  `json:"expanded"`
}

type ViewRequest struct {
	LogCursors []LogCursor `json:"logCursors"`
}

type ArtifactsViewItem struct {
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	Status string `json:"status"`
}

type ViewResponse struct {
	Artifacts []*ArtifactsViewItem `json:"artifacts"`
Repository: go-gitea/gitea
File: routers/web/org/org_labels.go (Go)

Code before:
	ctx.Data["SortType"] = ctx.FormString("sort")
}

// NewLabel create new label for organization
func NewLabel(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.CreateLabelForm)
	ctx.Data["Title"] = ctx.Tr("repo.labels")
	ctx.Data["PageIsLabels"] = true
	ctx.Data["PageIsOrgSettings"] = true

	if ctx.HasError() {
		ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
		ctx.Redirect(ctx.Org.OrgLink + "/settings/labels")
		return
	}

	l := &issues_model.Label{
		OrgID:          ctx.Org.Organization.ID,
		Name:           form.Title,
		Exclusive:      form.Exclusive,
		Description:    form.Description,
		Color:          form.Color,
		ExclusiveOrder: form.ExclusiveOrder,
	}
	if err := issues_model.NewLabel(ctx, l); err != nil {
		if label.IsErrInvalidLabelColor(err) {
			ctx.Flash.Error("NewLabel: " + err.Error())
		} else {
			ctx.ServerError("NewLabel", err)
			return
		}
	}
	ctx.Redirect(ctx.Org.OrgLink + "/settings/labels")
}

// UpdateLabel update a label's name and color
func UpdateLabel(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.CreateLabelForm)
	l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, form.ID)
	if err != nil {
		switch {
		case issues_model.IsErrOrgLabelNotExist(err):
			ctx.HTTPError(http.StatusNotFound)
		default:
			ctx.ServerError("UpdateLabel", err)
		}
		return
	}

	l.Name = form.Title
	l.Exclusive = form.Exclusive

Review comment (suggestion):
It makes the whole code base more complex: now there are at least 2 places doing "validation" and report errors:

* The `web.GetForm` and `ctx.HasError()` above
* The `NewLabel` or `UpdateLabel`

It makes the system more fragile ....

Code after:
	ctx.Data["Labels"] = labels
	ctx.Data["NumLabels"] = len(labels)
	ctx.Data["SortType"] = ctx.FormString("sort")
}

// NewLabel create new label for organization
func NewLabel(ctx *context.Context) {
	form := shared_label.GetLabelEditForm(ctx)
	if ctx.Written() {
		return
	}

	l := &issues_model.Label{
		OrgID:          ctx.Org.Organization.ID,
		Name:           form.Title,
		Exclusive:      form.Exclusive,
		Description:    form.Description,
		Color:          form.Color,
		ExclusiveOrder: form.ExclusiveOrder,
	}
	if err := issues_model.NewLabel(ctx, l); err != nil {
		ctx.ServerError("NewLabel", err)
		return
	}
	ctx.JSONRedirect(ctx.Org.OrgLink + "/settings/labels")
}

// UpdateLabel update a label's name and color
func UpdateLabel(ctx *context.Context) {
	form := shared_label.GetLabelEditForm(ctx)
	if ctx.Written() {
		return
	}

	l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, form.ID)
	if errors.Is(err, util.ErrNotExist) {
		ctx.JSONErrorNotFound()
		return
	} else if err != nil {
		ctx.ServerError("GetLabelInOrgByID", err)
		return
	}

	l.Name = form.Title
	l.Exclusive = form.Exclusive
	l.ExclusiveOrder = form.ExclusiveOrder
	l.Description = form.Description
	l.Color = form.Color
	l.SetArchived(form.IsArchived)
	if err := issues_model.UpdateLabel(ctx, l); err != nil {
		ctx.ServerError("UpdateLabel", err)
Repository: go-gitea/gitea
File: web_src/js/components/ViewFileTreeItem.vue (Vue)

Code before:
import {SvgIcon} from '../svg.ts';
import {ref} from 'vue';

type Item = {
  entryName: string;
  entryMode: string;
  entryIcon: string;
  entryIconOpen: string;
  fullPath: string;
  submoduleUrl?: string;
  children?: Item[];
};

const props = defineProps<{
  item: Item,
  navigateViewContent:(treePath: string) => void,
  loadChildren:(treePath: string, subPath?: string) => Promise<Item[]>,
  getWebUrl:(treePath: string) => string,
  selectedItem?: string,
}>();

const isLoading = ref(false);
const children = ref(props.item.children);
const collapsed = ref(!props.item.children);

const doLoadChildren = async (e?: MouseEvent) => {
  // the event is only not undefined if the user explicitly clicked on the directory item toggle. the preventDefault
  // stops the event from bubbling up and causing a directory content load
  e?.preventDefault();

  collapsed.value = !collapsed.value;
  if (!collapsed.value && props.loadChildren) {
    isLoading.value = true;
    try {
      children.value = await props.loadChildren(props.item.fullPath);
    } finally {
      isLoading.value = false;
    }
  }
};

const doLoadDirContent = (e: MouseEvent) => {
  // only load the directory content without a window refresh if the user didn't press any special key
  if (e.button !== 0 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
  e.preventDefault();

  doLoadChildren();
  props.navigateViewContent(props.item.fullPath);
};

const doLoadFileContent = (e: MouseEvent) => {

Review comment (suggestion):
```suggestion
const doLoadChildren = async (e: MouseEvent | null) => {
```

I guess I would prefer if you pass explicit null here to indicate the absence of a event.

Code after:
import {SvgIcon} from '../svg.ts';
import {isPlainClick} from '../utils/dom.ts';
import {ref} from 'vue';
import {type createViewFileTreeStore} from './ViewFileTreeStore.ts';

type Item = {
  entryName: string;
  entryMode: 'blob' | 'exec' | 'tree' | 'commit' | 'symlink' | 'unknown';
  entryIcon: string;
  entryIconOpen: string;
  fullPath: string;
  submoduleUrl?: string;
  children?: Item[];
};

const props = defineProps<{
  item: Item,
  store: ReturnType<typeof createViewFileTreeStore>
}>();

const store = props.store;
const isLoading = ref(false);
const children = ref(props.item.children);
const collapsed = ref(!props.item.children);

const doLoadChildren = async () => {
  collapsed.value = !collapsed.value;
  if (!collapsed.value) {
    isLoading.value = true;
    try {
      children.value = await store.loadChildren(props.item.fullPath);
    } finally {
      isLoading.value = false;
    }
  }
};

const onItemClick = (e: MouseEvent) => {
  // only handle the click event with page partial reloading if the user didn't press any special key
  // let browsers handle special keys like "Ctrl+Click"
  if (!isPlainClick(e)) return;
  e.preventDefault();
  if (props.item.entryMode === 'tree') doLoadChildren();
  store.navigateTreeView(props.item.fullPath);
};

</script>

<template>
  <a
    class="tree-item silenced"
Repository: go-gitea/gitea
File: services/repository/files/update.go (Go)

Code before:
				return ErrRepoFileAlreadyExists{
					Path: file.TreePath,
				}
			}
		}
	}

	// Remove the old path from the tree
	if file.Options.fromTreePath != file.Options.treePath && len(filesInIndex) > 0 {
		for _, indexFile := range filesInIndex {
			if indexFile == file.Options.fromTreePath {
				if err = t.RemoveFilesFromIndex(ctx, file.FromTreePath); err != nil {
					return err
				}
			}
		}
	}

	var writeObjectRet *writeRepoObjectRet
	switch file.Operation {
	case "create", "update":
		writeObjectRet, err = writeRepoObjectForCreateOrUpdate(ctx, t, file)
	case "rename":
		writeObjectRet, err = writeRepoObjectForRename(ctx, t, file)
	default:
		return util.NewInvalidArgumentErrorf("unknown operation: %s", file.Operation)
	}
	if err != nil {
		return err
	}

	// Add the object to the index
	if err = t.AddObjectToIndex(ctx, util.Iif(file.Options.executable, "100755", "100644"), writeObjectRet.ObjectHash, file.Options.treePath); err != nil {
		return err
	}

	if writeObjectRet.LfsContent == nil {
		return nil // No LFS pointer, so nothing to do
	}
	defer writeObjectRet.LfsContent.Close()

	// Now we must store the content into an LFS object
	lfsMetaObject, err := git_model.NewLFSMetaObject(ctx, repoID, writeObjectRet.LfsPointer)
	if err != nil {
		return err
	}
	if exist, err := contentStore.Exists(lfsMetaObject.Pointer); err != nil {
		return err
	} else if exist {
		return nil
	}

Review comment (suggestion):
```suggestion
		return util.NewInvalidArgumentErrorf("unknown file modification operation: '%s'", file.Operation)
```

Code after:
					Path: file.TreePath,
				}
			}
		}
	}

	// Remove the old path from the tree
	if file.Options.fromTreePath != file.Options.treePath && len(filesInIndex) > 0 {
		for _, indexFile := range filesInIndex {
			if indexFile == file.Options.fromTreePath {
				if err = t.RemoveFilesFromIndex(ctx, file.FromTreePath); err != nil {
					return err
				}
			}
		}
	}

	var writeObjectRet *writeRepoObjectRet
	switch file.Operation {
	case "create", "update":
		writeObjectRet, err = writeRepoObjectForCreateOrUpdate(ctx, t, file)
	case "rename":
		writeObjectRet, err = writeRepoObjectForRename(ctx, t, file)
	default:
		return util.NewInvalidArgumentErrorf("unknown file modification operation: '%s'", file.Operation)
	}
	if err != nil {
		return err
	}

	// Add the object to the index, the "file.Options.executable" is set in handleCheckErrors by the caller (legacy hacky approach)
	if err = t.AddObjectToIndex(ctx, util.Iif(file.Options.executable, "100755", "100644"), writeObjectRet.ObjectHash, file.Options.treePath); err != nil {
		return err
	}

	if writeObjectRet.LfsContent == nil {
		return nil // No LFS pointer, so nothing to do
	}
	defer writeObjectRet.LfsContent.Close()

	// Now we must store the content into an LFS object
	lfsMetaObject, err := git_model.NewLFSMetaObject(ctx, repoID, writeObjectRet.LfsPointer)
	if err != nil {
		return err
	}
	if exist, err := contentStore.Exists(lfsMetaObject.Pointer); err != nil {
		return err
	} else if exist {
		return nil
	}
Repository: go-gitea/gitea
File: models/migrations/v1_22/v294_test.go (Go)

Code before:

	// Prepare and load the testing database
	x, deferable := base.PrepareTestEnv(t, 0, new(ProjectIssue))
	defer deferable()
	if x == nil || t.Failed() {
		return
	}

	cnt, err := x.Table("project_issue").Where("project_id=1 AND issue_id=1").Count()
	assert.NoError(t, err)
	assert.EqualValues(t, 2, cnt)

	assert.NoError(t, AddUniqueIndexForProjectIssue(x))

	cnt, err = x.Table("project_issue").Where("project_id=1 AND issue_id=1").Count()
	assert.NoError(t, err)
	assert.EqualValues(t, 1, cnt)

	tables, err := x.DBMetas()
	assert.NoError(t, err)
	assert.Len(t, tables, 1)
	found := false
	for _, index := range tables[0].Indexes {
		if index.Type == schemas.UniqueType {
			found = true
			assert.True(t, slices.Equal(index.Cols, []string{"project_id", "issue_id"}))
			break
		}
	}
	assert.True(t, found)
}


Review comment (suggestion):
Not sure about the intention here, previous code was a noop because the `slices.Equal` result was not used. Let's see what CI says.

Code after:
	// Prepare and load the testing database
	x, deferable := base.PrepareTestEnv(t, 0, new(ProjectIssue))
	defer deferable()
	if x == nil || t.Failed() {
		return
	}

	cnt, err := x.Table("project_issue").Where("project_id=1 AND issue_id=1").Count()
	assert.NoError(t, err)
	assert.EqualValues(t, 2, cnt)

	assert.NoError(t, AddUniqueIndexForProjectIssue(x))

	cnt, err = x.Table("project_issue").Where("project_id=1 AND issue_id=1").Count()
	assert.NoError(t, err)
	assert.EqualValues(t, 1, cnt)

	tables, err := x.DBMetas()
	assert.NoError(t, err)
	assert.Len(t, tables, 1)
	found := false
	for _, index := range tables[0].Indexes {
		if index.Type == schemas.UniqueType {
			found = true
			assert.ElementsMatch(t, index.Cols, []string{"project_id", "issue_id"})
			break
		}
	}
	assert.True(t, found)
}
Repository: go-gitea/gitea
File: web_src/js/components/RepoCodeFrequency.vue (Vue)

Code before:

const {pageData} = window.config;

Chart.defaults.color = chartJsColors.text;
Chart.defaults.borderColor = chartJsColors.border;

Chart.register(
  TimeScale,
  LinearScale,
  Legend,
  PointElement,
  LineElement,
  Filler,
);

defineProps<{
  locale: {
    loadingTitle: string;
    loadingTitleFailed: string;
    loadingInfo: string;
  };
}>();

const isLoading = shallowRef(false);
const errorText = shallowRef('');
const repoLink = pageData.repoLink || [];
const data = shallowRef<DayData[]>([]);

onMounted(() => {
  fetchGraphData();
});

async function fetchGraphData() {
  isLoading.value = true;
  try {
    let response: Response;
    do {
      response = await GET(`${repoLink}/activity/code-frequency/data`);
      if (response.status === 202) {
        await sleep(1000); // wait for 1 second before retrying
      }
    } while (response.status === 202);
    if (response.ok) {
      const dayDataObject: DayDataObject = await response.json();
      const weekValues = Object.values(dayDataObject);
      const start = weekValues[0].week;
      const end = firstStartDateAfterDate(new Date());
      const startDays = startDaysBetween(start, end);
      data.value = fillEmptyStartDaysWithZeroes(startDays, dayDataObject);
      errorText.value = '';
    } else {

Review comment (suggestion):
```suggestion
const repoLink = pageData.repoLink;
```

Code after:

const {pageData} = window.config;

Chart.defaults.color = chartJsColors.text;
Chart.defaults.borderColor = chartJsColors.border;

Chart.register(
  TimeScale,
  LinearScale,
  Legend,
  PointElement,
  LineElement,
  Filler,
);

defineProps<{
  locale: {
    loadingTitle: string;
    loadingTitleFailed: string;
    loadingInfo: string;
  };
}>();

const isLoading = shallowRef(false);
const errorText = shallowRef('');
const repoLink = pageData.repoLink;
const data = shallowRef<DayData[]>([]);

onMounted(() => {
  fetchGraphData();
});

async function fetchGraphData() {
  isLoading.value = true;
  try {
    let response: Response;
    do {
      response = await GET(`${repoLink}/activity/code-frequency/data`);
      if (response.status === 202) {
        await sleep(1000); // wait for 1 second before retrying
      }
    } while (response.status === 202);
    if (response.ok) {
      const dayDataObject: DayDataObject = await response.json();
      const weekValues = Object.values(dayDataObject);
      const start = weekValues[0].week;
      const end = firstStartDateAfterDate(new Date());
      const startDays = startDaysBetween(start, end);
      data.value = fillEmptyStartDaysWithZeroes(startDays, dayDataObject);
      errorText.value = '';
    } else {