-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
189 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
apps/server/src/crawl/utils/filterNewFeaturesAndGlossaries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getFilePathDepth } from '@/utils/getFilePathDepth' | ||
import { DataReturn } from '../classificationCase' | ||
|
||
export function filterNewFeaturesAndGlossaries( | ||
dataReturn: DataReturn, | ||
fileChanges: Array<string>, | ||
) { | ||
// Ex of features path: projects/DeFi/features.json | ||
const file1 = fileChanges.filter((value) => getFilePathDepth(value) == 3) | ||
if (file1.length == 0) { | ||
dataReturn.features = [] | ||
dataReturn.glossaries = [] | ||
return fileChanges | ||
} | ||
|
||
dataReturn.features = [] | ||
dataReturn.glossaries = [] | ||
|
||
file1.forEach((value) => { | ||
if (value.includes('features.json')) { | ||
dataReturn.features.push(value) | ||
} else if (value.includes('glossaries.json')) { | ||
dataReturn.glossaries.push(value) | ||
} | ||
}) | ||
|
||
const filesReturn = fileChanges.filter( | ||
(value) => getFilePathDepth(value) !== 3, | ||
) | ||
return filesReturn | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DataReturn } from '../classificationCase' | ||
|
||
export function filterNewSocial( | ||
dataReturn: DataReturn, | ||
fileChanges: Array<string>, | ||
): Array<string> { | ||
if (fileChanges.includes('projects/socials.json')) { | ||
dataReturn.isSocialCreate = true | ||
const listFiles = fileChanges.filter( | ||
(value) => value !== 'projects/socials.json', | ||
) | ||
return listFiles | ||
} | ||
|
||
dataReturn.isSocialCreate = false | ||
return fileChanges | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { fsWrapper } from '@/utils/fs/fsWrapper' | ||
import { DataReturn } from '../classificationCase' | ||
|
||
function getProjectPath(file: string) { | ||
const array = file.split('/') | ||
|
||
return `${array[0]}/${array[1]}/${array[2]}/${array[3]}` | ||
} | ||
|
||
function getListProject(fileChange: Array<string>): Array<string> { | ||
const set = new Set<string>() | ||
|
||
fileChange.forEach((file) => { | ||
const path = getProjectPath(file) | ||
set.add(path) | ||
}) | ||
|
||
return Array.from(set) | ||
} | ||
|
||
export async function filterProject( // include new, update (new) and delete project | ||
dataReturn: DataReturn, | ||
fileChanges: Array<string>, | ||
) { | ||
if (fileChanges.length == 0) { | ||
dataReturn.projectUpdate = [] | ||
dataReturn.projectDelete = [] | ||
return | ||
} | ||
const projectPaths = getListProject(fileChanges) | ||
|
||
dataReturn.projectUpdate = [] | ||
dataReturn.projectDelete = [] | ||
|
||
await Promise.all( | ||
projectPaths.map((value) => fsWrapper.checkFileExist(value)), | ||
).then((values) => { | ||
values.forEach((value, index) => { | ||
if (value == true) { | ||
// that mean project exist => maybe this is an update or new | ||
dataReturn.projectUpdate.push(projectPaths[index]) | ||
} else { | ||
dataReturn.projectDelete.push(projectPaths[index]) | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function removeTrash(fileChanges: Array<string>) { | ||
if (fileChanges.includes('projects/projects.json')) { | ||
const files = fileChanges.filter( | ||
(value) => value !== 'projects/projects.json', | ||
) | ||
|
||
return files | ||
} | ||
|
||
return fileChanges | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { fsWrapper } from '@/utils/fs/fsWrapper' | ||
|
||
export async function updateFeatures(filePath: string) { | ||
// ex of filePath: /projects/... | ||
const dataRaw = await fsWrapper.readFile(filePath) | ||
const datas = JSON.parse(dataRaw) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function getFilePathDepth(path: string) { | ||
const array = path.split('/') | ||
return array.length | ||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Oops, something went wrong.