-
Notifications
You must be signed in to change notification settings - Fork 2
feat(core): add releasesFactory to set releases list #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
42e4d47
releaser logic
3388ShubinPavel 83636d1
add release to resolvers andtypedefs
3388ShubinPavel c34e2d5
rm release comms
3388ShubinPavel 7a787a9
add logs
3388ShubinPavel 4dcfda0
change db
3388ShubinPavel 0cd1107
Bump version up to 1.1.15
github-actions[bot] 111dc39
add comms in graphql and translate to eng
3388ShubinPavel f37f071
rm useless
3388ShubinPavel 6c1ea20
Merge branch 'feat-release' of https://github.com/codex-team/hawk.api…
3388ShubinPavel 1e189e9
fix
3388ShubinPavel 94ed684
add project req
3388ShubinPavel aac5d4d
add releaseId to extract from db
3388ShubinPavel 433a683
rm logs
3388ShubinPavel 982c813
Merge branch 'master' into feat-release
3388ShubinPavel e15dec2
Bump version up to 1.1.16
github-actions[bot] 7e075c0
merge release with project
3388ShubinPavel f6e5c26
Update project.js
3388ShubinPavel 6d8ceae
add logic to find filesize
3388ShubinPavel d331a5e
linter
3388ShubinPavel d7d6b33
Merge branch 'master' into feat-release
3388ShubinPavel de5d339
Bump version up to 1.1.17
github-actions[bot] bb1f812
rm redunant
3388ShubinPavel e629607
new type release
3388ShubinPavel a295cf3
rm tralingspace
3388ShubinPavel 10d52ce
rm redunant
3388ShubinPavel dcbc5b3
rm redunant
3388ShubinPavel c240521
add grouping
3388ShubinPavel e75de96
Bump version up to 1.1.18
github-actions[bot] 1147bf8
rm redunant import
3388ShubinPavel 300a877
Update releaseFactory.ts
3388ShubinPavel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
neSpecc marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,91 @@ | ||
| import { Collection, Db } from 'mongodb'; | ||
| import { ReleaseDBScheme } from '@hawk.so/types'; | ||
| import DataLoaders from '../dataLoaders'; | ||
|
|
||
| export default class ReleasesFactory { | ||
| /** | ||
| * Коллекция релизов | ||
| */ | ||
| private collection: Collection<ReleaseDBScheme>; | ||
|
|
||
| /** | ||
| * DataLoader для релизов | ||
| */ | ||
| private dataLoaders: DataLoaders; | ||
|
|
||
| /** | ||
| * Создаёт экземпляр фабрики релизов | ||
| * @param dbConnection - подключение к базе данных | ||
| * @param dataLoaders - экземпляр DataLoaders для батчинга запросов | ||
| */ | ||
| constructor(dbConnection: Db, dataLoaders: DataLoaders) { | ||
| this.collection = dbConnection.collection('releases'); | ||
| this.dataLoaders = dataLoaders; | ||
| console.log("[ReleasesFactory] Initialized with collection 'releases'"); | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * Получить релиз по его идентификатору с использованием DataLoader | ||
| * @param id - идентификатор релиза | ||
| */ | ||
| public async getReleaseById(id: string): Promise<ReleaseDBScheme | null> { | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log(`[ReleasesFactory] getReleaseById called with id: ${id}`); | ||
| try { | ||
| const release = await this.dataLoaders.releaseById.load(id); | ||
| console.log(`[ReleasesFactory] getReleaseById result:`, release); | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return release; | ||
| } catch (error) { | ||
| console.error(`[ReleasesFactory] Error in getReleaseById:`, error); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Получить все релизы | ||
| */ | ||
| public async getAllReleases(): Promise<ReleaseDBScheme[]> { | ||
| console.log(`[ReleasesFactory] getAllReleases called`); | ||
| try { | ||
| const releases = await this.collection.find({}).toArray(); | ||
| console.log(`[ReleasesFactory] getAllReleases returned ${releases.length} releases`); | ||
| return releases; | ||
| } catch (error) { | ||
| console.error(`[ReleasesFactory] Error in getAllReleases:`, error); | ||
| throw error; | ||
| } | ||
| } | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Получить релизы с пагинацией | ||
| * @param page - номер страницы (начиная с 1) | ||
| * @param limit - количество элементов на страницу | ||
| */ | ||
| public async getReleasesPaginated(page: number, limit: number): Promise<ReleaseDBScheme[]> { | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const skip = (page - 1) * limit; | ||
| console.log(`[ReleasesFactory] getReleasesPaginated called with page: ${page}, limit: ${limit}, skip: ${skip}`); | ||
| try { | ||
| const releases = await this.collection.find({}).skip(skip).limit(limit).toArray(); | ||
| console.log(`[ReleasesFactory] getReleasesPaginated returned ${releases.length} releases`); | ||
| return releases; | ||
| } catch (error) { | ||
| console.error(`[ReleasesFactory] Error in getReleasesPaginated:`, error); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Получить релизы по идентификатору проекта | ||
| * @param projectId - идентификатор проекта | ||
| */ | ||
| public async getReleasesByProjectId(projectId: string): Promise<ReleaseDBScheme[]> { | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log(`[ReleasesFactory] getReleasesByProjectId called with projectId: ${projectId}`); | ||
| try { | ||
| const releases = await this.collection.find({ projectId: projectId }).toArray(); | ||
| console.log(`[ReleasesFactory] getReleasesByProjectId returned ${releases.length} releases`); | ||
| return releases; | ||
| } catch (error) { | ||
| console.error(`[ReleasesFactory] Error in getReleasesByProjectId:`, error); | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,24 @@ | ||
| import ReleasesFactory from '../models/releaseFactory'; | ||
|
|
||
| export default { | ||
| Query: { | ||
| /** | ||
| * Fetch all releases or releases filtered by projectId | ||
| * @param {ResolverObj} _ - Parent object, not used | ||
| * @param {ResolverArgs} args - Query arguments | ||
| * @param {ContextFactories} context - Global GraphQL context with factories | ||
| * @returns {Promise<Release[]>} | ||
| */ | ||
| getReleases: async (_: any, args: { projectId?: string }, { factories }: any) => { | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try { | ||
| if (args.projectId) { | ||
| return await factories.releasesFactory.getReleasesByProjectId(args.projectId); | ||
| } | ||
| return await factories.releasesFactory.getAllReleases(); | ||
| } catch (error) { | ||
| console.error('Error fetching releases:', error); | ||
| throw new Error('Не удалось получить релизы'); | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }, | ||
| }, | ||
| }; | ||
This file contains hidden or 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 hidden or 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,76 @@ | ||
| import { gql } from 'apollo-server-express'; | ||
|
|
||
| export default gql` | ||
| """ | ||
| Release commit | ||
| """ | ||
| type Commit { | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| Hash of the commit | ||
| """ | ||
| hash: String! | ||
| """ | ||
| Commit author | ||
| """ | ||
| author: String! | ||
| """ | ||
| Commit title | ||
| """ | ||
| title: String! | ||
| """ | ||
| Commit creation date | ||
| """ | ||
| date: DateTime! | ||
| } | ||
| """ | ||
| Source map file details | ||
| """ | ||
| type SourceMapData { | ||
| """ | ||
| Source map filename | ||
| """ | ||
| mapFileName: String! | ||
| """ | ||
| Original source filename | ||
| """ | ||
| originFileName: String! | ||
| } | ||
| """ | ||
| Release data | ||
| """ | ||
| type Release { | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| Release name | ||
| """ | ||
| releaseName: String! @renameFrom(name: "release") | ||
e11sy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| Project ID associated with the release | ||
| """ | ||
| projectId: ID! | ||
| """ | ||
| Release commits | ||
| """ | ||
| commits: [Commit!]! | ||
| """ | ||
| Source maps associated with the release | ||
| """ | ||
| files: [SourceMapData!]! | ||
| } | ||
| extend type Query { | ||
| """ | ||
| Fetch list of releases. | ||
| If projectId is provided, fetch releases for the given project. | ||
| """ | ||
| getReleases(projectId: ID): [Release]! | ||
| } | ||
| `; | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant