Skip to content

Commit

Permalink
fix(#316): Changed the timestamp Object type for user microservice (#321
Browse files Browse the repository at this point in the history
)

* fix - 316: Changed the timestamp Object type

* Removed unused type

* updated the variable for the time stamp
  • Loading branch information
riginoommen authored May 19, 2020
1 parent 42436b1 commit 1c94bd8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 58 deletions.
2 changes: 1 addition & 1 deletion packages/user-service/src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class UserSyncCron {
newProfile[0].uid = response.uid;
newProfile[0].memberOf = groups;
newProfile[0].isActive = true;
newProfile[0].timestamp.modifiedAt = moment(new Date());
newProfile[0].updatedOn = moment( new Date() );
return User.findByIdAndUpdate(oldProfile[0]._id, newProfile[0], { new: true })
.exec();
}
Expand Down
5 changes: 2 additions & 3 deletions packages/user-service/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ export const UserGroupResolver = {
memberOf: groups,
isActive: true,
apiRole: ( groups.includes( 'one-portal-devel' ) ) ? `ADMIN` : 'USER',
timestamp: {
createdAt: moment.utc( new Date() )
}
createdBy: response.rhatUUID,
createdOn: moment.utc( new Date() )
} );
return newUser.save();
} else {
Expand Down
18 changes: 5 additions & 13 deletions packages/user-service/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@ export const UserSchema: Schema = new Schema({
isActive: Boolean,
memberOf: [String],
apiRole: String,
timestamp: {
createdAt: { type: Date, default: Date.now },
createdBy: {
uid: String,
name: String,
},
modifiedAt: { type: Date },
modifiedBy: {
uid: String,
name: String,
}
}
});
createdBy: String,
createdOn: Date,
updatedBy: String,
updatedOn: Date,
} );

interface UserModel extends UserType , Document { }

Expand Down
38 changes: 10 additions & 28 deletions packages/user-service/src/typedef.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,6 @@ type LdapType {
objectClass: [String]
}

type ProfileType {
kerberosID: String
name: String
}

type TimestampType {
createdAt: DateTime
createdBy: ProfileType
modifiedAt: DateTime
modifiedBy: ProfileType
}

input ProfileInput {
kerberosID: String
name: String
}

input TimestampInput {
createdAt: DateTime
createdBy: ProfileInput
modifiedAt: DateTime
modifiedBy: ProfileInput
}

type UserType {
_id: String
name: String
Expand All @@ -100,8 +76,11 @@ type UserType {
rhatUUID: String
memberOf: [String]
isActive: Boolean
apiRole: APIROLE,
timestamp: TimestampType
apiRole: APIROLE
createdBy: String
createdOn: DateTime
updatedBy: String
updatedOn: DateTime
}
input UserInput {
_id: String
Expand All @@ -111,8 +90,11 @@ input UserInput {
rhatUUID: String
memberOf: [String]
isActive: Boolean
apiRole: APIROLE,
timestamp: TimestampInput
apiRole: APIROLE
createdBy: String
createdOn: DateTime
updatedBy: String
updatedOn: DateTime
}

type Mutation {
Expand Down
17 changes: 4 additions & 13 deletions packages/user-service/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ type LdapType = {
objectClass?: string[];
}

type IUser = {
uid: string;
name: string;
}

type ITimestamp = {
createdAt: Date;
createdBy: IUser;
modifiedAt?: Date;
modifiedBy?: IUser;
}

type UserType = {
name: string;
title: string;
Expand All @@ -84,5 +72,8 @@ type UserType = {
isActive ?: boolean;
memberOf: string[];
apiRole: string,
timestamp ?: ITimestamp;
createdBy: string;
createdOn: Date;
updatedBy: string;
updatedOn: Date;
}

0 comments on commit 1c94bd8

Please sign in to comment.