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
8c7335f8
Commit
8c7335f8
authored
Aug 23, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tmp clock
parent
1b6e065e
Pipeline
#4931
passed with stage
in 4 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
console-api/src/entities/ArchiveFile.entity.ts
console-api/src/entities/ArchiveFile.entity.ts
+2
-1
console-api/src/update/update.service.ts
console-api/src/update/update.service.ts
+36
-2
No files found.
console-api/src/entities/ArchiveFile.entity.ts
View file @
8c7335f8
import
{
Entity
,
ManyToOne
,
PrimaryColumn
}
from
'
typeorm
'
;
import
{
Entity
,
Index
,
ManyToOne
,
PrimaryColumn
}
from
'
typeorm
'
;
import
{
Archive
}
from
'
./Archive.entity
'
;
@
Entity
()
...
...
@@ -6,6 +6,7 @@ export class ArchiveFile {
@
ManyToOne
(()
=>
Archive
,
(
a
)
=>
a
.
containingFiles
,
{
primary
:
true
,
onDelete
:
'
CASCADE
'
})
archive
:
Archive
;
@
Index
()
@
PrimaryColumn
(
'
varchar
'
,
{
length
:
256
})
path
:
string
;
...
...
console-api/src/update/update.service.ts
View file @
8c7335f8
...
...
@@ -8,6 +8,9 @@ import { BlankReturnMessageDto } from '../dto/ReturnMessage.dto';
import
{
Archive
,
ArchiveType
}
from
'
../entities/Archive.entity
'
;
import
{
PackageS3Service
}
from
'
../package-s3/package-s3.service
'
;
import
_
from
'
lodash
'
;
import
{
ArchiveFile
}
from
'
../entities/ArchiveFile.entity
'
;
import
*
as
os
from
'
os
'
;
import
moment
from
'
moment
'
;
@
Injectable
()
export
class
UpdateService
extends
ConsoleLogger
{
...
...
@@ -135,6 +138,8 @@ export class UpdateService extends ConsoleLogger {
}
async
getPartPackageMetalink
(
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
,
requestedFiles
:
string
[])
{
let
clock
=
moment
();
this
.
log
(
'
part 1
'
);
const
tryExactArchives
=
await
this
.
getArchives
(
id
,
depotDto
,
...
...
@@ -142,7 +147,21 @@ export class UpdateService extends ConsoleLogger {
(
qb
)
=>
qb
.
andWhere
(
'
archive.role != :partRole
'
,
{
partRole
:
ArchiveType
.
Part
})
.
andWhere
(
'
:requestedFiles = archive.files
'
,
{
requestedFiles
:
requestedFiles
})
/*.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
...
...
@@ -153,11 +172,25 @@ export class UpdateService extends ConsoleLogger {
archives
:
tryExactArchives
,
};
}
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
(
'
:requestedFiles && archive.files
'
,
{
requestedFiles
:
requestedFiles
})
.
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
})
);
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
})
);
...
...
@@ -165,6 +198,7 @@ export class UpdateService extends ConsoleLogger {
if
(
fullArchive
&&
this
.
getCostOfArchives
([
fullArchive
])
<=
this
.
getCostOfArchives
(
allPartArchives
))
{
archives
=
[
fullArchive
];
}
this
.
log
(
`Time used:
${
moment
().
diff
(
clock
,
'
seconds
'
)}
s`
);
return
{
cdnUrl
:
this
.
cdnUrl
,
archives
,
...
...
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