monkeeShark/packages/backend/src/models/repositories
Johann150 804fa33535
refactor: improve code quality (#8751)
* remove unnecessary if

`Array.prototype.some` already returns a boolean so an if to return
true or false is completely unnecessary in this case.

* perf: use count instead of find

When using `count` instead of `findOneBy`, the data is not
unnecessarily loaded.

* remove duplicate null check

The variable is checked for null in the lines above and the function
returns if so. Therefore, it can not be null at this point.

* simplify `getJsonSchema`

Because the assigned value is `null` and the used keys are only
shallow, use of `nestedProperty.set` seems inappropriate. Because the
value is not read, the initial for loop can be replaced by a `for..in`
loop.

Since all keys will be assigned `null`, the condition of the ternary
expression in the nested function will always be true. Therefore the
recursion case will never happen. With this the nested function can be
eliminated.

* remove duplicate condition

The code above already checks `dragging` and returns if it is truthy.
Checking it again later is therefore unnecessary.

To make this more obvious the `return` is removed in favour of using
an if...else construct.

* remove impossible "unknown" time

The `ago` variable will always be a number and all non-negative numbers
are already covered by other cases, the negative case is handled with
`future` so there is no case when `unkown` could be achieved.
2022-05-29 15:15:52 +09:00
..
abuse-user-report.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
antenna.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
app.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
auth-session.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
blocking.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
channel.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
clip.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
drive-file.ts refactor: use structuredClone for deep clone 2022-04-23 12:38:02 +09:00
drive-folder.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
emoji.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
follow-request.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
following.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
gallery-like.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
gallery-post.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
hashtag.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
instance.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
messaging-message.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
moderation-logs.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
muting.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
note-favorite.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
note-reaction.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
note.ts refactor: improve code quality (#8751) 2022-05-29 15:15:52 +09:00
notification.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
page-like.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
page.ts refactor: fix type 2022-04-17 12:59:41 +09:00
relay.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
signin.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
user-group-invitation.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
user-group.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
user-list.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
user.ts refactor: improve code quality (#8751) 2022-05-29 15:15:52 +09:00