This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
generated from KennethTrecy/web_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(revert): readd the filters for reconstruction
This reverts commit 62415d8. This reverts commit 8605dce. This reverts commit 6c04053. This reverts commit 9b36ca3. This reverts commit 4da4c88. This reverts commit b1c30d3. This reverts commit 993d9bf. This reverts commit 98fde69.
- Loading branch information
1 parent
5c6dd97
commit 1641bb9
Showing
65 changed files
with
1,711 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { | ||
ProfanityFilterResourceIdentifier, | ||
ProfanityFilterAttributes, | ||
ProfanityFilterResource, | ||
DeserializedProfanityFilterResource, | ||
ProfanityFilterDocument, | ||
ProfanityFilterListDocument, | ||
DeserializedProfanityFilterDocument, | ||
DeserializedProfanityFilterListDocument | ||
} from "$/types/documents/profanity_filter" | ||
|
||
import { PROFANITY_FILTER_LINK } from "$/constants/template_links" | ||
|
||
import BaseFetcher from "$@/fetchers/base" | ||
|
||
export default class ProfanityFilterFetcher extends BaseFetcher< | ||
ProfanityFilterResourceIdentifier<"read">, | ||
ProfanityFilterAttributes<"serialized">, | ||
ProfanityFilterAttributes<"deserialized">, | ||
ProfanityFilterResource, | ||
DeserializedProfanityFilterResource, | ||
ProfanityFilterDocument, | ||
ProfanityFilterListDocument, | ||
DeserializedProfanityFilterDocument, | ||
DeserializedProfanityFilterListDocument | ||
> { | ||
constructor() { | ||
super(PROFANITY_FILTER_LINK) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Factory from "~/factories/found_comment_word" | ||
import Manager from "./found_comment_word" | ||
|
||
describe("Database Manager: Post profanity filter read operations", () => { | ||
it("can check if model belongs to comment", async() => { | ||
const manager = new Manager() | ||
const model = await new Factory().insertOne() | ||
|
||
const foundModel = await manager.findFoundCommentWord( | ||
model.commentID, model.profanityFilterID) | ||
|
||
expect(foundModel).not.toBeNull() | ||
expect(foundModel).toHaveProperty("id", model.id) | ||
}) | ||
}) | ||
|
||
describe("Database Manager: Miscellaneous comment profanity filter operations", () => { | ||
it("can get sortable columns", () => { | ||
// Include in test to alert in case there are new columns to decide whether to expose or not | ||
const manager = new Manager() | ||
|
||
const { sortableColumns } = manager | ||
|
||
expect(sortableColumns).toStrictEqual([]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { CommonQueryParameters } from "$/types/query" | ||
import type { FoundCommentWordAttributes } from "$/types/documents/found_comment_word" | ||
import type { | ||
ModelCtor | ||
} from "%/types/dependent" | ||
|
||
import Model from "%/models/found_comment_word" | ||
import BaseManager from "%/managers/base" | ||
import Condition from "%/helpers/condition" | ||
import Transformer from "%/transformers/found_comment_word" | ||
|
||
export default class extends BaseManager< | ||
Model, | ||
FoundCommentWordAttributes<"deserialized">, | ||
CommonQueryParameters | ||
> { | ||
get model(): ModelCtor<Model> { return Model } | ||
|
||
get transformer(): Transformer { return new Transformer() } | ||
|
||
get exposableColumns(): string[] { | ||
return [] | ||
} | ||
|
||
async findFoundCommentWord(commentID: number, profanityFilterID: number): Promise<Model|null> { | ||
try { | ||
const attachedRole = await Model.findOne({ | ||
"where": new Condition().and( | ||
new Condition().equal("commentID", commentID), | ||
new Condition().equal("profanityFilterID", profanityFilterID) | ||
).build(), | ||
...this.transaction.transactionObject | ||
}) | ||
|
||
return attachedRole | ||
} catch (error) { | ||
throw this.makeBaseError(error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Factory from "~/factories/found_post_word" | ||
import Manager from "./found_post_word" | ||
|
||
describe("Database Manager: Post profanity filter read operations", () => { | ||
it("can check if model belongs to post", async() => { | ||
const manager = new Manager() | ||
const model = await new Factory().insertOne() | ||
|
||
const foundModel = await manager.findFoundPostWord(model.postID, model.profanityFilterID) | ||
|
||
expect(foundModel).not.toBeNull() | ||
expect(foundModel).toHaveProperty("id", model.id) | ||
}) | ||
}) | ||
|
||
describe("Database Manager: Miscellaneous post profanity filter operations", () => { | ||
it("can get sortable columns", () => { | ||
// Include in test to alert in case there are new columns to decide whether to expose or not | ||
const manager = new Manager() | ||
|
||
const { sortableColumns } = manager | ||
|
||
expect(sortableColumns).toStrictEqual([]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { CommonQueryParameters } from "$/types/query" | ||
import type { FoundPostWordAttributes } from "$/types/documents/found_post_word" | ||
import type { | ||
ModelCtor | ||
} from "%/types/dependent" | ||
|
||
import Model from "%/models/found_post_word" | ||
import BaseManager from "%/managers/base" | ||
import Condition from "%/helpers/condition" | ||
import Transformer from "%/transformers/found_post_word" | ||
|
||
export default class extends BaseManager< | ||
Model, | ||
FoundPostWordAttributes<"deserialized">, | ||
CommonQueryParameters | ||
> { | ||
get model(): ModelCtor<Model> { return Model } | ||
|
||
get transformer(): Transformer { return new Transformer() } | ||
|
||
get exposableColumns(): string[] { | ||
return [] | ||
} | ||
|
||
async findFoundPostWord(postID: number, profanityFilterID: number): Promise<Model|null> { | ||
try { | ||
const attachedRole = await Model.findOne({ | ||
"where": new Condition().and( | ||
new Condition().equal("postID", postID), | ||
new Condition().equal("profanityFilterID", profanityFilterID) | ||
).build(), | ||
...this.transaction.transactionObject | ||
}) | ||
|
||
return attachedRole | ||
} catch (error) { | ||
throw this.makeBaseError(error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Manager from "./profanity_filter" | ||
|
||
describe("Database Manager: Miscellaneous semester operations", () => { | ||
it("can get sortable columns", () => { | ||
// Include in test to alert in case there are new columns to decide whether to expose or not | ||
const manager = new Manager() | ||
|
||
const { sortableColumns } = manager | ||
|
||
expect(sortableColumns).toStrictEqual([ | ||
"-createdAt", | ||
"-deletedAt", | ||
"-id", | ||
"-updatedAt", | ||
"-word", | ||
"createdAt", | ||
"deletedAt", | ||
"id", | ||
"updatedAt", | ||
"word" | ||
]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { CommonQueryParameters } from "$/types/query" | ||
import type { ModelCtor } from "%/types/dependent" | ||
import type { ProfanityFilterAttributes } from "$/types/documents/profanity_filter" | ||
|
||
import BaseManager from "%/managers/base" | ||
import ProfanityFilter from "%/models/profanity_filter" | ||
|
||
import ProfanityFilterTransformer from "%/transformers/profanity_filter" | ||
|
||
export default class extends BaseManager< | ||
ProfanityFilter, | ||
ProfanityFilterAttributes<"deserialized">, | ||
CommonQueryParameters | ||
> { | ||
get model(): ModelCtor<ProfanityFilter> { return ProfanityFilter } | ||
|
||
get transformer(): ProfanityFilterTransformer { return new ProfanityFilterTransformer() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Model, | ||
Table, | ||
Column, | ||
BelongsTo, | ||
ForeignKey | ||
} from "sequelize-typescript" | ||
|
||
import ProfanityFilter from "%/models/profanity_filter" | ||
import Comment from "%/models/comment" | ||
|
||
@Table({ | ||
"paranoid": true, | ||
"timestamps": true | ||
}) | ||
export default class FoundCommentWord extends Model { | ||
@ForeignKey(() => Comment) | ||
@Column({ | ||
"allowNull": false | ||
}) | ||
commentID!: number | ||
|
||
@BelongsTo(() => Comment) | ||
comment!: Comment | ||
|
||
@ForeignKey(() => ProfanityFilter) | ||
@Column({ | ||
"allowNull": false | ||
}) | ||
profanityFilterID!: number | ||
|
||
@BelongsTo(() => ProfanityFilter) | ||
profanityFilter!: ProfanityFilter | ||
} |
Oops, something went wrong.