Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
a46f171d
Commit
a46f171d
authored
Aug 24, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into file-relation
parents
8c7335f8
183a4730
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
38 deletions
+61
-38
console-api/src/app.module.ts
console-api/src/app.module.ts
+1
-1
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+1
-1
console-api/src/update/update.service.ts
console-api/src/update/update.service.ts
+59
-36
No files found.
console-api/src/app.module.ts
View file @
a46f171d
...
...
@@ -40,7 +40,7 @@ const configModule = ConfigModule.forRoot();
username
:
config
.
get
(
'
DB_USER
'
),
password
:
config
.
get
(
'
DB_PASS
'
),
database
:
config
.
get
(
'
DB_NAME
'
),
//logging: true
,
logging
:
!!
config
.
get
(
'
DB_LOGGING
'
)
,
};
},
}),
...
...
console-api/src/packager/packager.service.ts
View file @
a46f171d
...
...
@@ -47,7 +47,7 @@ export class ArchiveTask {
const
archive
=
new
Archive
();
archive
.
path
=
this
.
path
;
archive
.
role
=
this
.
role
;
archive
.
files
=
[]
;
archive
.
files
=
this
.
exactFilePaths
;
archive
.
containingFiles
=
this
.
exactFilePaths
.
map
((
filePath
)
=>
ArchiveFile
.
fromPath
(
filePath
));
return
archive
;
}
...
...
console-api/src/update/update.service.ts
View file @
a46f171d
...
...
@@ -138,34 +138,33 @@ export class UpdateService extends ConsoleLogger {
}
async
getPartPackageMetalink
(
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
,
requestedFiles
:
string
[])
{
const
build
=
await
this
.
getBuild
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
select
(
'
build.id
'
));
let
clock
=
moment
();
this
.
log
(
'
part 1
'
);
const
tryExactArchives
=
await
this
.
getArchives
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
andWhere
(
'
archive.role != :partRole
'
,
{
partRole
:
ArchiveType
.
Part
})
/*.addSelect(`array(${qb
const
tryExactArchiveQuery
=
this
.
db
.
getRepository
(
Archive
)
.
createQueryBuilder
(
'
archive
'
)
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
andWhere
(
'
archive.role != :partRole
'
,
{
partRole
:
ArchiveType
.
Part
});
/*.addSelect(`array(${qb
.subQuery()
.select('file.path')
.from(ArchiveFile, 'file')
.where('file.archiveId = archive.id')
.getQuery()})`, 'allFiles')*/
.
andWhere
(
`:requestedFiles = array(
${
qb
.
subQuery
()
.
select
(
'
file.path
'
)
.
from
(
ArchiveFile
,
'
file
'
)
.
where
(
'
file.archiveId = archive.id
'
)
.
getQuery
()}
)`
,
{
requestedFiles
:
requestedFiles
}
)
// .orderBy('archive.size', 'ASC'
)
.
limit
(
1
),
true
);
tryExactArchiveQuery
.
andWhere
(
`:requestedFiles = array(
${
tryExactArchiveQuery
.
subQuery
(
)
.
select
(
'
file.path
'
)
.
from
(
ArchiveFile
,
'
file
'
)
.
where
(
'
file.archiveId = archive.id
'
)
.
getQuery
()}
)`
,
{
requestedFiles
:
requestedFiles
}
)
// .orderBy('archive.size', 'ASC')
.
limit
(
1
);
const
tryExactArchives
=
await
tryExactArchiveQuery
.
getMany
(
);
if
(
tryExactArchives
.
length
)
{
return
{
cdnUrl
:
this
.
cdnUrl
,
...
...
@@ -173,27 +172,51 @@ export class UpdateService extends ConsoleLogger {
};
}
this
.
log
(
`Time used:
${
moment
().
diff
(
clock
,
'
seconds
'
)}
s`
);
/*clock = moment();
this.log('part ex');
const archiveIds: number[] = (
await this.db
.createQueryBuilder()
.select('distinct(file.archiveId)', 'archiveId')
.from(ArchiveFile, 'file')
.where('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.innerJoin('file.archive', 'archive')
.andWhere('archive.buildId = :buildId', { buildId: build.id })
.getRawMany()
).map((obj) => obj.archiveId);
this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);*/
clock
=
moment
();
this
.
log
(
'
part 2
'
);
const
allPartArchives
=
await
this
.
getArchives
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
andWhere
(
`exists
${
qb
.
subQuery
()
.
select
(
'
file.path
'
)
.
from
(
ArchiveFile
,
'
file
'
)
.
where
(
'
file.archiveId = archive.id
'
)
.
andWhere
(
'
file.path = any(:requestedFiles)
'
,
{
requestedFiles
:
requestedFiles
})
.
getQuery
()}
`
)
.
andWhere
(
'
archive.role = :partRole
'
,
{
partRole
:
ArchiveType
.
Part
})
const
allPartArchivesQuery
=
this
.
db
.
getRepository
(
Archive
)
.
createQueryBuilder
(
'
archive
'
)
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
andWhere
(
'
archive.role = :partRole
'
,
{
partRole
:
ArchiveType
.
Part
});
//.innerJoin('archive.containingFiles', 'file')
//.andWhere('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles });
allPartArchivesQuery
.
andWhere
(
`exists
${
allPartArchivesQuery
.
subQuery
()
.
select
(
'
file.path
'
)
.
from
(
ArchiveFile
,
'
file
'
)
.
where
(
'
file.archiveId = archive.id
'
)
.
andWhere
(
'
file.path = any(:requestedFiles)
'
,
{
requestedFiles
:
requestedFiles
})
.
getQuery
()}
`
);
const
allPartArchives
=
await
allPartArchivesQuery
.
getMany
();
this
.
log
(
`Time used:
${
moment
().
diff
(
clock
,
'
seconds
'
)}
s`
);
clock
=
moment
();
this
.
log
(
'
part 3
'
);
const
[
fullArchive
]
=
await
this
.
getArchives
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
andWhere
(
'
archive.role = :fullRole
'
,
{
fullRole
:
ArchiveType
.
Full
})
);
const
fullArchive
=
await
this
.
db
.
getRepository
(
Archive
)
.
createQueryBuilder
(
'
archive
'
)
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
andWhere
(
'
archive.role = :fullRole
'
,
{
fullRole
:
ArchiveType
.
Full
})
.
limit
(
1
)
.
getOne
();
let
archives
=
allPartArchives
;
if
(
fullArchive
&&
this
.
getCostOfArchives
([
fullArchive
])
<=
this
.
getCostOfArchives
(
allPartArchives
))
{
archives
=
[
fullArchive
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment