Skip to content

Commit

Permalink
Merge pull request #105 from icefoganalytics/issue-104/fix-datasets-t…
Browse files Browse the repository at this point in the history
…able-render-crash-from-bad-acronym

Fix Datasets Table Render Crash From Bad Acronym
  • Loading branch information
klondikemarlen authored Jun 7, 2024
2 parents 18d6873 + da8581c commit 25ddffb
Show file tree
Hide file tree
Showing 14 changed files with 1,190 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Migration } from "@/db/umzug"
import { UserGroup } from "@/models"

export const up: Migration = async () => {
await UserGroup.findEach(async (userGroup) => {
await userGroup.update({
name: userGroup.name.trim().replace(/\s+/g, " "),
})
})
}

export const down: Migration = async () => {
// no-op
}
4 changes: 2 additions & 2 deletions api/src/models/user-groups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Model,
DataTypes,
InferAttributes,
InferCreationAttributes,
Expand All @@ -24,6 +23,7 @@ import {

import sequelize from "@/db/db-client"
import UserGroupMembership from "@/models/user-group-membership"
import BaseModel from "@/models/base-model"

export enum UserGroupTypes {
DEPARTMENT = "department",
Expand All @@ -35,7 +35,7 @@ export enum UserGroupTypes {
export const UNASSIGNED_USER_GROUP_NAME = "Unassigned"
export const DEFAULT_ORDER = -1

export class UserGroup extends Model<
export class UserGroup extends BaseModel<
InferAttributes<UserGroup>,
InferCreationAttributes<UserGroup>
> {
Expand Down
20 changes: 12 additions & 8 deletions api/src/services/user-groups/sync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class SyncService extends BaseService {

const [userGroup1] = await UserGroup.findOrCreate({
where: {
name: department,
name: this.cleanName(department),
type: UserGroupTypes.DEPARTMENT,
},
defaults: {
name: department,
name: this.cleanName(department),
type: UserGroupTypes.DEPARTMENT,
order: DEFAULT_ORDER,
},
Expand All @@ -36,12 +36,12 @@ export class SyncService extends BaseService {
const [userGroup2] = await UserGroup.findOrCreate({
where: {
parentId: userGroup1.id,
name: division,
name: this.cleanName(division),
type: UserGroupTypes.DIVISION,
},
defaults: {
parentId: userGroup1.id,
name: division,
name: this.cleanName(division),
type: UserGroupTypes.DIVISION,
order: DEFAULT_ORDER,
},
Expand All @@ -55,12 +55,12 @@ export class SyncService extends BaseService {
const [userGroup3] = await UserGroup.findOrCreate({
where: {
parentId: userGroup2.id,
name: branch,
name: this.cleanName(branch),
type: UserGroupTypes.BRANCH,
},
defaults: {
parentId: userGroup2.id,
name: branch,
name: this.cleanName(branch),
type: UserGroupTypes.BRANCH,
order: DEFAULT_ORDER,
},
Expand All @@ -74,12 +74,12 @@ export class SyncService extends BaseService {
await UserGroup.findOrCreate({
where: {
parentId: userGroup3.id,
name: unit,
name: this.cleanName(unit),
type: UserGroupTypes.UNIT,
},
defaults: {
parentId: userGroup3.id,
name: unit,
name: this.cleanName(unit),
type: UserGroupTypes.UNIT,
order,
},
Expand Down Expand Up @@ -117,6 +117,10 @@ export class SyncService extends BaseService {
return UserGroup.findAll()
}
}

private cleanName(name: string) {
return name.trim().replace(/\s+/g, " ")
}
}

export default SyncService
22 changes: 11 additions & 11 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ services:
db:
condition: service_healthy

# test_web:
# build:
# context: ./web
# dockerfile: development.Dockerfile
# command: /bin/true
# environment:
# <<: *default-environment
# NODE_ENV: test
# tty: true
# volumes:
# - ./web:/usr/src/web
test_web:
build:
context: ./web
dockerfile: development.Dockerfile
command: /bin/true
environment:
<<: *default-environment
NODE_ENV: test
tty: true
volumes:
- ./web:/usr/src/web

db:
image: mcr.microsoft.com/mssql/server:2022-latest
Expand Down
2 changes: 1 addition & 1 deletion web/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
extraFileExtensions: [".vue"],
parser: "@typescript-eslint/parser",
tsconfigRootDir: __dirname,
project: ["./tsconfig.node.json", "./tsconfig.json"],
project: ["./tsconfig.node.json", "./tsconfig.json", "./tsconfig.eslint.json"],
sourceType: "module",
},
plugins: ["vue", "@typescript-eslint"],
Expand Down
Loading

0 comments on commit 25ddffb

Please sign in to comment.