diff --git a/backend/src/database/migrations/U1674065473__isEnrichedToLastEnriched.sql b/backend/src/database/migrations/U1674065473__isEnrichedToLastEnriched.sql new file mode 100644 index 0000000000..f365a5a726 --- /dev/null +++ b/backend/src/database/migrations/U1674065473__isEnrichedToLastEnriched.sql @@ -0,0 +1,2 @@ +ALTER TABLE public."members" ADD COLUMN "isEnriched" BOOLEAN DEFAULT false; +ALTER TABLE public."members" DROP COLUMN "lastEnriched"; \ No newline at end of file diff --git a/backend/src/database/migrations/V1674065473__isEnrichedToLastEnriched.sql b/backend/src/database/migrations/V1674065473__isEnrichedToLastEnriched.sql new file mode 100644 index 0000000000..7c4701abb7 --- /dev/null +++ b/backend/src/database/migrations/V1674065473__isEnrichedToLastEnriched.sql @@ -0,0 +1,2 @@ +ALTER TABLE public."members" DROP COLUMN "isEnriched"; +ALTER TABLE public."members" ADD COLUMN "lastEnriched" TIMESTAMP DEFAULT NULL; \ No newline at end of file diff --git a/backend/src/database/models/member.ts b/backend/src/database/models/member.ts index 3164290c69..dcee2dbac7 100644 --- a/backend/src/database/models/member.ts +++ b/backend/src/database/models/member.ts @@ -54,9 +54,8 @@ export default (sequelize) => { total: -1, }, }, - isEnriched: { - type: DataTypes.BOOLEAN, - defaultValue: false, + lastEnriched: { + type: DataTypes.DATE, }, }, { diff --git a/backend/src/database/repositories/__tests__/memberRepository.test.ts b/backend/src/database/repositories/__tests__/memberRepository.test.ts index 550c4fd5dc..ee99fce913 100644 --- a/backend/src/database/repositories/__tests__/memberRepository.test.ts +++ b/backend/src/database/repositories/__tests__/memberRepository.test.ts @@ -68,7 +68,7 @@ describe('MemberRepository tests', () => { email: member2add.email, score: member2add.score, identities: ['github'], - isEnriched: false, + lastEnriched: null, organizations: [], notes: [], tasks: [], @@ -141,7 +141,7 @@ describe('MemberRepository tests', () => { displayName: member2add.displayName, attributes: member2add.attributes, email: member2add.email, - isEnriched: false, + lastEnriched: null, score: member2add.score, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -179,7 +179,7 @@ describe('MemberRepository tests', () => { attributes: {}, identities: ['github'], email: null, - isEnriched: false, + lastEnriched: null, score: -1, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -318,7 +318,7 @@ describe('MemberRepository tests', () => { identities: ['github'], attributes: {}, email: null, - isEnriched: false, + lastEnriched: null, score: -1, importHash: null, organizations: [], @@ -369,7 +369,7 @@ describe('MemberRepository tests', () => { id: memberCreated.id, username: member2add.username, displayName: member2add.displayName, - isEnriched: false, + lastEnriched: null, attributes: {}, email: null, score: -1, @@ -1303,7 +1303,7 @@ describe('MemberRepository tests', () => { attributes: updateFields.attributes, email: updateFields.email, score: updateFields.score, - isEnriched: false, + lastEnriched: null, organizations: [], importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1391,7 +1391,7 @@ describe('MemberRepository tests', () => { username: updateFields.username, displayName: returnedMember.displayName, attributes: updateFields.attributes, - isEnriched: false, + lastEnriched: null, email: updateFields.email, score: updateFields.score, importHash: null, @@ -1454,7 +1454,7 @@ describe('MemberRepository tests', () => { email: member1.email, score: member1.score, organizations: [], - isEnriched: false, + lastEnriched: null, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), updatedAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1536,7 +1536,7 @@ describe('MemberRepository tests', () => { email: member1.email, score: member1.score, tags: [], - isEnriched: false, + lastEnriched: null, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), updatedAt: SequelizeTestUtils.getNowWithoutTime(), diff --git a/backend/src/database/repositories/memberRepository.ts b/backend/src/database/repositories/memberRepository.ts index 4fca45ecc5..05f1148b9e 100644 --- a/backend/src/database/repositories/memberRepository.ts +++ b/backend/src/database/repositories/memberRepository.ts @@ -32,7 +32,7 @@ class MemberRepository { 'displayName', 'attributes', 'email', - 'isEnriched', + 'lastEnriched', 'score', 'reach', 'joinedAt', @@ -211,7 +211,7 @@ class MemberRepository { const currentTenant = SequelizeRepository.getCurrentTenant(options) const query = - 'SELECT "id", "username", "displayName", "attributes", "email", "score", "isEnriched", "reach", "joinedAt", "importHash", "createdAt", "updatedAt", "deletedAt", "tenantId", "createdById", "updatedById" FROM "members" AS "member" WHERE ("member"."deletedAt" IS NULL AND ("member"."tenantId" = $tenantId AND ("member"."username"->>$platform) = $username)) LIMIT 1;' + 'SELECT "id", "username", "displayName", "attributes", "email", "score", "lastEnriched", "reach", "joinedAt", "importHash", "createdAt", "updatedAt", "deletedAt", "tenantId", "createdById", "updatedById" FROM "members" AS "member" WHERE ("member"."deletedAt" IS NULL AND ("member"."tenantId" = $tenantId AND ("member"."username"->>$platform) = $username)) LIMIT 1;' const records = await options.database.sequelize.query(query, { type: Sequelize.QueryTypes.SELECT, @@ -259,7 +259,7 @@ class MemberRepository { 'displayName', 'attributes', 'email', - 'isEnriched', + 'lastEnriched', 'score', 'reach', 'joinedAt', @@ -797,7 +797,7 @@ class MemberRepository { 'displayName', 'email', 'score', - 'isEnriched', + 'lastEnriched', 'joinedAt', 'importHash', 'reach', @@ -874,7 +874,7 @@ class MemberRepository { 'email', 'tenantId', 'score', - 'isEnriched', + 'lastEnriched', 'joinedAt', 'importHash', 'createdAt', diff --git a/backend/src/services/__tests__/memberService.test.ts b/backend/src/services/__tests__/memberService.test.ts index 22cf1fc9e0..f83a82b3ec 100644 --- a/backend/src/services/__tests__/memberService.test.ts +++ b/backend/src/services/__tests__/memberService.test.ts @@ -150,7 +150,7 @@ describe('MemberService tests', () => { updatedById: mockIServiceOptions.currentUser.id, reach: { total: -1 }, joinedAt: new Date('2020-05-28T15:13:30Z'), - isEnriched: false, + lastEnriched: null, } expect(memberCreated).toStrictEqual(memberExpected) @@ -256,7 +256,7 @@ describe('MemberService tests', () => { updatedById: mockIServiceOptions.currentUser.id, reach: { total: -1 }, joinedAt: new Date('2020-05-28T15:13:30Z'), - isEnriched: false, + lastEnriched: null, } expect(memberCreated).toStrictEqual(memberExpected) @@ -339,7 +339,7 @@ describe('MemberService tests', () => { tenantId: mockIServiceOptions.currentTenant.id, createdById: mockIServiceOptions.currentUser.id, updatedById: mockIServiceOptions.currentUser.id, - isEnriched: false, + lastEnriched: null, reach: { total: -1 }, joinedAt: new Date('2020-05-28T15:13:30Z'), } @@ -378,7 +378,7 @@ describe('MemberService tests', () => { displayName: username, attributes: {}, email: member1.email, - isEnriched: false, + lastEnriched: null, score: member1.score, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -423,7 +423,7 @@ describe('MemberService tests', () => { }, displayName: username, attributes: {}, - isEnriched: false, + lastEnriched: null, email: member1.email, score: member1.score, importHash: null, @@ -471,7 +471,7 @@ describe('MemberService tests', () => { attributes: {}, email: member1.email, score: member1.score, - isEnriched: false, + lastEnriched: null, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), updatedAt: SequelizeTestUtils.getNowWithoutTime(), @@ -886,7 +886,7 @@ describe('MemberService tests', () => { default: attributes[MemberAttributeName.LOCATION][PlatformType.GITHUB], }, }, - isEnriched: false, + lastEnriched: null, email: member1.email, score: member1.score, importHash: null, @@ -992,7 +992,7 @@ describe('MemberService tests', () => { default: attributes2[MemberAttributeName.LOCATION][PlatformType.GITHUB], }, }, - isEnriched: false, + lastEnriched: null, email: member1.email, score: member1.score, importHash: null, @@ -1090,7 +1090,7 @@ describe('MemberService tests', () => { }, }, email: member1.email, - isEnriched: false, + lastEnriched: null, score: member1.score, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1264,7 +1264,7 @@ describe('MemberService tests', () => { }, }, email: member1.email, - isEnriched: false, + lastEnriched: null, score: member1.score, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1313,7 +1313,7 @@ describe('MemberService tests', () => { [PlatformType.GITHUB]: member1Username, }, displayName: member1Username, - isEnriched: false, + lastEnriched: null, reach: { total: 10, [PlatformType.GITHUB]: 10 }, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1364,7 +1364,7 @@ describe('MemberService tests', () => { username: { [PlatformType.GITHUB]: member1Username, }, - isEnriched: false, + lastEnriched: null, displayName: member1Username, reach: { total: 10, [PlatformType.GITHUB]: 10 }, importHash: null, @@ -1417,7 +1417,7 @@ describe('MemberService tests', () => { username: { [PlatformType.GITHUB]: member1Username, }, - isEnriched: false, + lastEnriched: null, displayName: member1Username, reach: { total: 36, [PlatformType.GITHUB]: 15, linkedin: 11, [PlatformType.TWITTER]: 10 }, importHash: null, @@ -1471,7 +1471,7 @@ describe('MemberService tests', () => { [PlatformType.GITHUB]: member1Username, }, displayName: member1Username, - isEnriched: false, + lastEnriched: null, reach: { total: 50, [PlatformType.GITHUB]: 30, linkedin: 10, [PlatformType.TWITTER]: 10 }, importHash: null, createdAt: SequelizeTestUtils.getNowWithoutTime(), @@ -1714,7 +1714,7 @@ describe('MemberService tests', () => { [PlatformType.GITHUB]: member1.username.github, [PlatformType.DISCORD]: member2.username.discord, }, - isEnriched: false, + lastEnriched: null, displayName: member1.displayName, identities: [PlatformType.GITHUB, PlatformType.DISCORD], activities: [activityCreated],