Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Intel quicky 2 to implement 1 #51

Merged
merged 8 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Intel implements IIntel {
calendar: calendarData.data.user,
};

github.converter.run(data);
await github.converter.run(data);
} else if (platform === "gitlab") {
let gitlabClient: GitlabClient;

Expand Down
135 changes: 135 additions & 0 deletions src/reducer/database/osm/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ abstract class BaseSO {
*/
abstract objects: SOAssembler;

/**
* @description Defines the osm table name.
*/
abstract tableName(): string;

//> Static Methods
/**
* @static
Expand Down Expand Up @@ -182,6 +187,16 @@ abstract class PlatformSO extends BaseSO {
*/
abstract getCalendar(dates: any): object;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "platform";
}

//> Model Implementation Example
// class PlatformModel extends PlatformSO{
// /**
Expand Down Expand Up @@ -253,6 +268,16 @@ abstract class MemberSO extends BaseSO {
//> Static Fields
static statements = member;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "member";
}

//> Model Implementation Example
// class MemberModel extends MemberSO{
// /**
Expand Down Expand Up @@ -361,6 +386,16 @@ abstract class RepositorySO extends BaseSO {
*/
abstract getLanguages(fields: any): LanguageSO[];

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "repository";
}

//> Model Implementation Example
// class RepositoryModel extends RepositorySO{
// /**
Expand Down Expand Up @@ -432,6 +467,16 @@ abstract class RepositoryHasMemberSO extends BaseSO {
//> Static Fields
static statements = repositoryHasMember;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "repositoryhasmember";
}

//> Model Implementation Example
// class RepositoryHasMemberModel extends RepositoryHasMemberSO{
// /**
Expand Down Expand Up @@ -504,6 +549,16 @@ abstract class LanguageSO extends BaseSO {
//> Static Fields
static statements = language;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "language";
}

//> Model Implementation Example
// class LanguageModel extends LanguageSO{
// /**
Expand Down Expand Up @@ -576,6 +631,16 @@ abstract class PlatformHasRepositorySO extends BaseSO {
//> Static Fields
static statements = platformHasRepository;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "platformhasrepository";
}

//> Model Implementation Example
// class PlatformHasRepositoryModel extends PlatformHasRepositorySO{
// /**
Expand Down Expand Up @@ -674,6 +739,16 @@ abstract class OrganizationSO extends BaseSO {
*/
abstract getRepositories(): RepositorySO[];

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "organization";
}

//> Model Implementation Example
// class OrganizationModel extends OrganizationSO{
// /**
Expand Down Expand Up @@ -745,6 +820,16 @@ abstract class OrganizationHasMemberSO extends BaseSO {
//> Static Fields
static statements = organizationHasMember;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "organizationhasmember";
}

//> Model Implementation Example
// class OrganizationHasMemberModel extends OrganizationHasMemberSO{
// /**
Expand Down Expand Up @@ -820,6 +905,16 @@ abstract class PlatformHasOrganizationSO extends BaseSO {
//> Static Fields
static statements = platformHasOrganization;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "platformhasorganization";
}

//> Model Implementation Example
// class PlatformHasOrganizationModel extends PlatformHasOrganizationSO{
// /**
Expand Down Expand Up @@ -1009,6 +1104,16 @@ abstract class StatisticSO extends BaseSO {
total: number;
};

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "statistic";
}

//> Model Implementation Example
// class StatisticModel extends StreakSO{
// /**
Expand Down Expand Up @@ -1079,6 +1184,16 @@ abstract class StreakSO extends BaseSO {
//> Static Fields
static statements = streak;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "streak";
}

//> Model Implementation Example
// class StreakModel extends StreakSO{
// /**
Expand Down Expand Up @@ -1248,6 +1363,16 @@ abstract class CalendarSO extends BaseSO {
*/
abstract createContribution(fields: any): ContributionSO;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "calendar";
}

//> Model Implementation Example
// class CalendarModel extends CalendarSO{
// /**
Expand Down Expand Up @@ -1318,6 +1443,16 @@ abstract class ContributionSO extends BaseSO {
//> Static Fields
static statements = contribution;

//> Methods
/**
* @static
* @returns {string} A table name.
* @description Returns the database table name of this osm model.
*/
tableName() {
return "contribution";
}

//> Model Implementation Example
// class ContributionModel extends ContributionSO{
// /**
Expand Down
6 changes: 3 additions & 3 deletions src/reducer/database/osm/reconstructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SOAssembler {
*/
create(fields: any) {
try {
let tablename = new this.Base({}).constructor.name.toLowerCase();
let tablename = new this.Base({}).tableName();

SOAssembler.database.exec(
this.Base.statements.create,
Expand Down Expand Up @@ -134,7 +134,7 @@ class SOAssembler {
if ({}.hasOwnProperty.call(response, entry)) {
for (let f in filter) {
if ({}.hasOwnProperty.call(filter, f)) {
/**
/**
* Proxy to neutralize Generic Object Injection Sink.
* @todo Validate the proxy workaround for the injection vulnerability via a penetration test.
* @see {@link https://bit.ly/2KdpgAh |the-dangers-of-square-bracket-notation}
Expand All @@ -149,7 +149,7 @@ class SOAssembler {
}
);

/**
/**
* Proxy to neutralize Generic Object Injection Sink.
* @todo Validate the proxy workaround for the injection vulnerability via a penetration test.
* @see {@link https://bit.ly/2KdpgAh |the-dangers-of-square-bracket-notation}
Expand Down
10 changes: 8 additions & 2 deletions src/reducer/helper/profile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//#region > Imports
//> Lodash
// Contains a method to create a deep copy of a object
import cloneDeep from 'lodash.clonedeep';
import cloneDeep from "lodash.clonedeep";

//> Models
// Contains all models of the database
import * as models from "../database/models";
//> Delay
// Contains a Delay function for timeouts
import Delay from "../../toolbox/Delay";
//#endregion

//#region > Interfaces
Expand Down Expand Up @@ -69,7 +73,7 @@ interface IOrganization extends models.Organization {
* @returns A merged profile object.
* @description Get all profile information. Platform nr. 1 is used for general information.
*/
function mergedProfile() {
async function mergedProfile() {
let platform = models.Platform.objects.get({ id: 1 }) as IPlatform;
let repositories = models.Repository.objects.all() as IRepository[];
let organizations = models.Organization.objects.all() as IOrganization[];
Expand All @@ -88,6 +92,7 @@ function mergedProfile() {

return repository.render([]);
});
await Delay(1000);

platform.organizations = organizations.map((organization) => {
organization.members = organization.getMembers().map((member) => {
Expand Down Expand Up @@ -124,6 +129,7 @@ function mergedProfile() {

return organization.render([]);
});
await Delay(1000);

platform.render([]);

Expand Down
16 changes: 12 additions & 4 deletions src/reducer/helper/statistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as models from "../database/models";
//> Helper
// Contains all calendar helper functions
import * as helper from "./index";
//> Delay
// Contains a Delay function for timeouts
import Delay from "../../toolbox/Delay";
//> Interfaces
//> Contains the share interface for the languages
import { Share } from "../database/osm/models";
Expand Down Expand Up @@ -57,7 +60,7 @@ interface IStatistic extends models.Statistic {
* Streaks: A object which contains longest, current and a list of streaks.
*/
streak: {
/**
/**
* Longest: The streak with the longest difference between
* startDate and endDate.
*/
Expand All @@ -81,13 +84,16 @@ interface IStatistic extends models.Statistic {
* @returns A statistic object.
* @description Returns a object containing e.g busiest day and streaks of current and each year.
*/
function mergedStatistic(): IStatisticResponse {
async function mergedStatistic(): Promise<IStatisticResponse> {
let statistic = models.Statistic.getMerged() as IStatistic[];

let currentYear: IStatistic | null = null;
let yearsList: IStatistic[] = [];

statistic.forEach((entry) => {
for (const index in statistic) {
await Delay(300);

let entry = statistic[index];
let streaks = entry.getStreaks().map((streak) => {
return streak.render([]);
});
Expand Down Expand Up @@ -121,7 +127,9 @@ function mergedStatistic(): IStatisticResponse {

yearsList.push(entry);
}
});
}

await Delay(2500);

/* Get the merged languages which contains a list of language object */
const languages = helper.language.mergedLanguage();
Expand Down
6 changes: 3 additions & 3 deletions src/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Reducer {
* @returns {object} A object with profile, calendar, statistic and language information.
* @description Get a object which contains profile, calendar, statistic and language information.
*/
get() {
async get() {
return {
profile: helper.profile.mergedProfile(),
statistic: helper.statistic.mergedStatistic(),
profile: await helper.profile.mergedProfile(),
statistic: await helper.statistic.mergedStatistic(),
};
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/toolbox/Delay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//#region > Functions
/**
* @function
* @param {number} ms A time in milliseconds.
* @returns {Promise<unknown>} A timeout promise.
* @description A function to set a timeout.
*/
function Delay(ms: number): Promise<unknown> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
//#endregion

//#region > Exports
export default Delay;
//#endregion
Loading