Skip to content

Commit

Permalink
Deploying to gh-pages from @ b3b4cee 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Nov 14, 2023
1 parent d742de5 commit 0f6a06a
Show file tree
Hide file tree
Showing 98 changed files with 2,407 additions and 2,506 deletions.
14 changes: 7 additions & 7 deletions classes/UserLoginMigrationAlreadyClosedLoggableException.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h3 id="constructor">Constructor</h3>
<tbody>
<tr>
<td class="col-md-4">
<code>constructor(userLoginMigrationId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, closedAt: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" target="_blank">Date</a>)</code>
<code>constructor(closedAt: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" target="_blank">Date</a>, userLoginMigrationId?: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>)</code>
</td>
</tr>
<tr>
Expand All @@ -145,10 +145,10 @@ <h3 id="constructor">Constructor</h3>
</thead>
<tbody>
<tr>
<td>userLoginMigrationId</td>
<td>closedAt</td>

<td>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId</a></code>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" target="_blank" >Date</a></code>
</td>

<td>
Expand All @@ -157,14 +157,14 @@ <h3 id="constructor">Constructor</h3>

</tr>
<tr>
<td>closedAt</td>
<td>userLoginMigrationId</td>

<td>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" target="_blank" >Date</a></code>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId</a></code>
</td>

<td>
No
Yes
</td>

</tr>
Expand Down Expand Up @@ -235,7 +235,7 @@ <h3 id="methods">
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from &#x27;@src/core/logger&#x27;;

export class UserLoginMigrationAlreadyClosedLoggableException extends UnprocessableEntityException implements Loggable {
constructor(private readonly userLoginMigrationId: EntityId, private readonly closedAt: Date) {
constructor(private readonly closedAt: Date, private readonly userLoginMigrationId?: EntityId) {
super();
}

Expand Down
6 changes: 3 additions & 3 deletions classes/UserLoginMigrationMandatoryLoggable.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h3 id="constructor">Constructor</h3>
<tbody>
<tr>
<td class="col-md-4">
<code>constructor(userId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, userLoginMigrationId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, mandatory: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank">boolean</a>)</code>
<code>constructor(userId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, userLoginMigrationId: <a href="../undefineds/EntityId.html" target="_self">EntityId | undefined</a>, mandatory: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank">boolean</a>)</code>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -154,7 +154,7 @@ <h3 id="constructor">Constructor</h3>
<td>userLoginMigrationId</td>

<td>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId</a></code>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId | undefined</a></code>
</td>

<td>
Expand Down Expand Up @@ -242,7 +242,7 @@ <h3 id="methods">
export class UserLoginMigrationMandatoryLoggable implements Loggable {
constructor(
private readonly userId: EntityId,
private readonly userLoginMigrationId: EntityId,
private readonly userLoginMigrationId: EntityId | undefined,
private readonly mandatory: boolean
) {}

Expand Down
6 changes: 3 additions & 3 deletions classes/UserLoginMigrationStartLoggable.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h3 id="constructor">Constructor</h3>
<tbody>
<tr>
<td class="col-md-4">
<code>constructor(userId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, userLoginMigrationId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>)</code>
<code>constructor(userId: <a href="../undefineds/EntityId.html" target="_self">EntityId</a>, userLoginMigrationId: <a href="../undefineds/EntityId.html" target="_self">EntityId | undefined</a>)</code>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -154,7 +154,7 @@ <h3 id="constructor">Constructor</h3>
<td>userLoginMigrationId</td>

<td>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId</a></code>
<code><a href="../miscellaneous/typealiases.html#EntityId" target="_self" >EntityId | undefined</a></code>
</td>

<td>
Expand Down Expand Up @@ -228,7 +228,7 @@ <h3 id="methods">
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from &#x27;@src/core/logger&#x27;;

export class UserLoginMigrationStartLoggable implements Loggable {
constructor(private readonly userId: EntityId, private readonly userLoginMigrationId: EntityId) {}
constructor(private readonly userId: EntityId, private readonly userLoginMigrationId: EntityId | undefined) {}

getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage {
return {
Expand Down
14 changes: 1 addition & 13 deletions coverage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13807,18 +13807,6 @@
<span class="coverage-count">(0/4)</span>
</td>
</tr>
<tr class="low">
<td>
<!-- miscellaneous -->
<a href="./interfaces/SchoolMigrationFlags.html">apps/server/src/modules/user-login-migration/service/dto/school-migration-flags.ts</a>
</td>
<td>interface</td>
<td>SchoolMigrationFlags</td>
<td align="right" data-sort="0">
<span class="coverage-percent">0 %</span>
<span class="coverage-count">(0/3)</span>
</td>
</tr>
<tr class="low">
<td>
<!-- miscellaneous -->
Expand All @@ -13828,7 +13816,7 @@
<td>MigrationCheckService</td>
<td align="right" data-sort="0">
<span class="coverage-percent">0 %</span>
<span class="coverage-count">(0/3)</span>
<span class="coverage-count">(0/5)</span>
</td>
</tr>
<tr class="low">
Expand Down
207 changes: 192 additions & 15 deletions injectables/MigrationCheckService.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ <h6><b>Methods</b></h6>
<td class="col-md-4">
<ul class="index-list">
<li>
<span class="modifier">Private</span>
<a href="#isMigrationActive" >isMigrationActive</a>
</li>
<li>
<span class="modifier">Private</span>
<a href="#isUserMigrated" >isUserMigrated</a>
</li>
<li>
<span class="modifier">Public</span>
<span class="modifier">Async</span>
<a href="#shouldUserMigrate" >shouldUserMigrate</a>
</li>
Expand Down Expand Up @@ -178,12 +187,163 @@ <h3 id="constructor">Constructor</h3>
<h3 id="methods">
Methods
</h3>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="isMigrationActive"></a>
<span class="name">
<span class="modifier">Private</span>
<span ><b>isMigrationActive</b></span>
<a href="#isMigrationActive"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<span class="modifier-icon icon ion-ios-reset"></span>
<code>isMigrationActive(userLoginMigration: <a href="../classes/UserLoginMigrationDO.html" target="_self">UserLoginMigrationDO</a>)</code>
</td>
</tr>


<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="47"
class="link-to-prism">apps/server/src/modules/user-login-migration/service/migration-check.service.ts:47</a></div>
</td>
</tr>


<tr>
<td class="col-md-4">

<div class="io-description">
<b>Parameters :</b>

<table class="params">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
</tr>
</thead>
<tbody>
<tr>
<td>userLoginMigration</td>
<td>
<code><a href="../classes/UserLoginMigrationDO.html" target="_self" >UserLoginMigrationDO</a></code>
</td>

<td>
No
</td>


</tr>
</tbody>
</table>
</div>
<div class="io-description">
<b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code>

</div>
<div class="io-description">

</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="isUserMigrated"></a>
<span class="name">
<span class="modifier">Private</span>
<span ><b>isUserMigrated</b></span>
<a href="#isUserMigrated"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<span class="modifier-icon icon ion-ios-reset"></span>
<code>isUserMigrated(user: <a href="../interfaces/User.html" target="_self">UserDO | null</a>, userLoginMigration: <a href="../classes/UserLoginMigrationDO.html" target="_self">UserLoginMigrationDO</a>)</code>
</td>
</tr>


<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="41"
class="link-to-prism">apps/server/src/modules/user-login-migration/service/migration-check.service.ts:41</a></div>
</td>
</tr>


<tr>
<td class="col-md-4">

<div class="io-description">
<b>Parameters :</b>

<table class="params">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
</tr>
</thead>
<tbody>
<tr>
<td>user</td>
<td>
<code><a href="../interfaces/User.html" target="_self" >UserDO | null</a></code>
</td>

<td>
No
</td>


</tr>
<tr>
<td>userLoginMigration</td>
<td>
<code><a href="../classes/UserLoginMigrationDO.html" target="_self" >UserLoginMigrationDO</a></code>
</td>

<td>
No
</td>


</tr>
</tbody>
</table>
</div>
<div class="io-description">
<b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code>

</div>
<div class="io-description">

</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="shouldUserMigrate"></a>
<span class="name">
<span class="modifier">Public</span>
<span class="modifier">Async</span>
<span ><b>shouldUserMigrate</b></span>
<a href="#shouldUserMigrate"><span class="icon ion-ios-link"></span></a>
Expand Down Expand Up @@ -277,11 +437,11 @@ <h3 id="methods">


<div class="tab-pane fade tab-source-code" id="source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from &#x27;@nestjs/common&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { LegacySchoolService } from &#x27;@modules/legacy-school&#x27;;
import { UserService } from &#x27;@modules/user&#x27;;
import { Injectable } from &#x27;@nestjs/common&#x27;;
import { EntityId, LegacySchoolDo, UserDO, UserLoginMigrationDO } from &#x27;@shared/domain&#x27;;
import { UserLoginMigrationRepo } from &#x27;@shared/repo&#x27;;
import { LegacySchoolService } from &#x27;@modules/legacy-school&#x27;;
import { UserService } from &#x27;@modules/user&#x27;;

@Injectable()
export class MigrationCheckService {
Expand All @@ -291,23 +451,40 @@ <h3 id="methods">
private readonly userLoginMigrationRepo: UserLoginMigrationRepo
) {}

async shouldUserMigrate(externalUserId: string, systemId: EntityId, officialSchoolNumber: string): Promise&lt;boolean&gt; {
public async shouldUserMigrate(
externalUserId: string,
systemId: EntityId,
officialSchoolNumber: string
): Promise&lt;boolean&gt; {
const school: LegacySchoolDo | null &#x3D; await this.schoolService.getSchoolBySchoolNumber(officialSchoolNumber);

if (school &amp;&amp; school.id) {
const userLoginMigration: UserLoginMigrationDO | null &#x3D; await this.userLoginMigrationRepo.findBySchoolId(
school.id
);
if (!school?.id) {
return false;
}

const user: UserDO | null &#x3D; await this.userService.findByExternalId(externalUserId, systemId);
const userLoginMigration: UserLoginMigrationDO | null &#x3D; await this.userLoginMigrationRepo.findBySchoolId(school.id);

if (user?.lastLoginSystemChange &amp;&amp; userLoginMigration &amp;&amp; !userLoginMigration.closedAt) {
const hasMigrated: boolean &#x3D; user.lastLoginSystemChange &gt; userLoginMigration.startedAt;
return !hasMigrated;
}
return !!userLoginMigration &amp;&amp; !userLoginMigration.closedAt;
if (!userLoginMigration || !this.isMigrationActive(userLoginMigration)) {
return false;
}
return false;

const user: UserDO | null &#x3D; await this.userService.findByExternalId(externalUserId, systemId);

if (this.isUserMigrated(user, userLoginMigration)) {
return false;
}

return true;
}

private isUserMigrated(user: UserDO | null, userLoginMigration: UserLoginMigrationDO): boolean {
return (
!!user &amp;&amp; user.lastLoginSystemChange !&#x3D;&#x3D; undefined &amp;&amp; user.lastLoginSystemChange &gt; userLoginMigration.startedAt
);
}

private isMigrationActive(userLoginMigration: UserLoginMigrationDO): boolean {
return !userLoginMigration.closedAt;
}
}
</code></pre>
Expand Down
Loading

0 comments on commit 0f6a06a

Please sign in to comment.