Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Test/public/project_item.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ function Test_GetItemDirect_SUCCESS{
Assert-AreEqual -Expected $contentId -Presented $result.contentId

}
function Test_GetItemDirect_SUCCESS_WithCache{
Assert-NotImplemented
}

function Test_ShowProjectItem_SUCCESS{

Expand Down
4 changes: 2 additions & 2 deletions include/databaseV2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Reset-DatabaseStore{

$databaseRoot = Invoke-MyCommand -Command GetDatabaseStorePath

Remove-Item -Path $databaseRoot -Recurse -Force -ErrorAction SilentlyContinue
Microsoft.PowerShell.Management\Remove-Item -Path $databaseRoot -Recurse -Force -ErrorAction SilentlyContinue

New-Item -Path $databaseRoot -ItemType Directory

Expand Down Expand Up @@ -55,7 +55,7 @@ function Reset-Database{
[Parameter(Position = 0)][string]$Key
)
$path = Get-DatabaseFile -Key $Key
Remove-Item -Path $path -Force -ErrorAction SilentlyContinue
Microsoft.PowerShell.Management\Remove-Item -Path $path -Force -ErrorAction SilentlyContinue
return
}

Expand Down
3 changes: 3 additions & 0 deletions private/item/convertItemToHash.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function Convert-NodeItemToHash {
$item.url = $NodeItem.content.url
$item.state = $NodeItem.content.state

$item.projectId = $NodeItem.project.id
$item.projectUrl = $NodeItem.project.url

$item.createdAt = GetDateTime -DateTimeString $NodeItem.content.createdAt
$item.updatedAt = GetDateTime -DateTimeString $NodeItem.content.updatedAt

Expand Down
20 changes: 16 additions & 4 deletions private/projectDatabase/project_database.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,29 @@ function Set-ProjectDatabaseV2{
$db.items = $items
$db.fields = $fields

Save-ProjectDatabase -Database $db -Owner $owner -ProjectNumber $projectnumber
Save-ProjectDatabase -Database $db
}

function Save-ProjectDatabase{
[CmdletBinding()]
param(
[Parameter(Position = 0)][string]$Owner,
[Parameter(Position = 1)][int]$ProjectNumber,
[Parameter(Position = 2)][hashtable]$Database
[Parameter(Position = 0)][hashtable]$Database
)

$owner = $Database.owner
$projectnumber = $Database.number

if($null -eq $Database){
throw "Database parameter is required"
}

if([string]::IsNullOrWhiteSpace($owner)){
throw "Database.owner is null or empty"
}
if($projectnumber -le 0){
throw "Database.number is null or not a positive integer"
}

$dbkey = Get-DatabaseKey -Owner $owner -ProjectNumber $projectnumber
Save-Database -Key $dbkey -Database $Database
}
Expand Down
4 changes: 2 additions & 2 deletions private/projectDatabase/project_database_Async.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Sync-ProjectDatabaseAsync {
$db = Sync-ProjectAsync -Database $db -SyncBatchSize $SyncBatchSize

# Saved changes to database
Save-ProjectDatabase -Database $db -Owner $Owner -ProjectNumber $ProjectNumber
Save-ProjectDatabase -Database $db

if (Test-ProjectDatabaseStaged -Owner $Owner -ProjectNumber $ProjectNumber) {
"Still pending staged values" | Write-MyError
Expand Down Expand Up @@ -100,7 +100,7 @@ function Sync-ProjectAsync {
Remove-ItemStaged -Database $db -ItemId $call.itemId -FieldId $call.FieldId
}

Save-ProjectDatabase -Database $db -Owner $Owner -ProjectNumber $ProjectNumber
Save-ProjectDatabase -Database $db

return $db
}
Expand Down
14 changes: 13 additions & 1 deletion private/projectDatabase/project_database_Item.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

function Set-Item{
[CmdletBinding()]
[OutputType([string])]
param(
[Parameter(Position = 0)][object[]]$Database,
[Parameter(ValueFromPipeline, Position = 1)][PSCustomObject]$Item
Expand All @@ -52,6 +51,19 @@

}

function Remove-Item{

Check warning

Code scanning / PSScriptAnalyzer

'Remove-Item' is a cmdlet that is included with PowerShell (version core-6.1.0-windows) whose definition should not be overridden Warning

'Remove-Item' is a cmdlet that is included with PowerShell (version core-6.1.0-windows) whose definition should not be overridden

Check warning

Code scanning / PSScriptAnalyzer

Function 'Remove-Item' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'. Warning

Function 'Remove-Item' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
[CmdletBinding()]
param(
[Parameter(Position = 0)][object[]]$Database,
Comment thread Fixed
[Parameter(ValueFromPipeline, Position = 1)][string]$ItemId
Comment thread Fixed
)

process{
$Database.items.Remove($ItemId) | Out-Null
}

}

function Set-ItemValue{
[CmdletBinding()]
[OutputType([string])]
Expand Down
2 changes: 1 addition & 1 deletion private/projectDatabase/project_database_Sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Sync-ProjectDatabase{
# Send update to project
$db = Sync-Project -Database $db

Save-ProjectDatabase -Database $db -Owner $Owner -ProjectNumber $ProjectNumber
Save-ProjectDatabase -Database $db

if (Test-ProjectDatabaseStaged -Owner $Owner -ProjectNumber $ProjectNumber) {
"Still pending staged values" | Write-MyError
Expand Down
1 change: 1 addition & 0 deletions private/projectDatabase/project_database_call.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function GetItemInfo {
# TODO: Situation where we are updating an item that is not cached and therefore type is not known
if (-not $item.type) {
# Single fetch item from api
# Avoid caching as we are beeing called from a Database modification context
$item = Get-ProjectItemDirect -ItemId $ItemId
}

Expand Down
149 changes: 78 additions & 71 deletions public/graphql/addItemToProject.mutant
Original file line number Diff line number Diff line change
@@ -1,91 +1,98 @@

mutation AddItem($input:AddProjectV2ItemByIdInput!){addProjectV2ItemById(input:$input){item{content{__typename,... on DraftIssue{id,body,title
},... on PullRequest{body,title,number,url,repository{nameWithOwner
mutation AddItem($input:AddProjectV2ItemByIdInput!){addProjectV2ItemById(input:$input){
item{
id, type,
project{ id, url},
content{__typename,
... on DraftIssue {id,body,title,updatedAt,createdAt},
... on PullRequest{id,body,title,updatedAt,createdAt,number,url,state,repository{nameWithOwner}},
... on Issue{id,body,title,updatedAt,createdAt,number,url,state,repository{nameWithOwner}
},
}
fieldValues(first: 100){
nodes{__typename,
... on ProjectV2ItemFieldDateValue{date,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
},... on Issue{body,title,number,url,repository{nameWithOwner
}
},... on ProjectV2ItemFieldIterationValue{title,startDate,duration,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
},id,fieldValues(first: 100){nodes{__typename,... on ProjectV2ItemFieldDateValue{date,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
},... on ProjectV2ItemFieldLabelValue{labels(first: 10){nodes{name
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldIterationValue{title,startDate,duration,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
},iterationId
},... on ProjectV2ItemFieldLabelValue{labels(first: 10){nodes{name
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldNumberValue{number,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldNumberValue{number,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldSingleSelectValue{name,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldSingleSelectValue{name,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldTextValue{text,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldTextValue{text,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldMilestoneValue{milestone{title,description,dueOn
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldMilestoneValue{milestone{title,description,dueOn
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldPullRequestValue{pullRequests(first: 10){nodes{url
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldPullRequestValue{pullRequests(first: 10){nodes{url
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldRepositoryValue{repository{url
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldRepositoryValue{repository{url
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldUserValue{users(first: 10){nodes{login
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
},... on ProjectV2ItemFieldUserValue{users(first: 10){nodes{login
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
},... on ProjectV2ItemFieldReviewerValue{reviewers(first: 10){nodes{__typename,... on Team{name
},... on User{login
}
},... on ProjectV2ItemFieldReviewerValue{reviewers(first: 10){nodes{__typename,... on Team{name
},... on User{login
}
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
},field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
}
}
}
}
}

}
}
}
1 change: 1 addition & 0 deletions public/graphql/getProjectV2Item.query
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ query($itemId: ID!) {
node(id: $itemId) {
... on ProjectV2Item {
id, type,
project{ id, url},
content{__typename,
... on DraftIssue {id,body,title,updatedAt,createdAt},
... on PullRequest{id,body,title,updatedAt,createdAt,number,url,state,repository{nameWithOwner}},
Expand Down
8 changes: 6 additions & 2 deletions public/graphql/orgprojectwithfieldsAndItems.query
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
query OrgProjectWithFields($afterFields:String$afterItems:String$firstFields:Int!$firstItems:Int!$login:String!$number:Int!){organization(login: $login){projectV2(number: $number){number,url,shortDescription,public,closed,title,id,readme,items(first: $firstItems, after: $afterItems){pageInfo{endCursor,hasNextPage
},totalCount,nodes{content{__typename
},totalCount,
nodes{
project{ id, number, title, url},
content{__typename
,... on DraftIssue {id,body,title,updatedAt,createdAt
},... on PullRequest{id,body,title,updatedAt,createdAt,number,url,state,repository{nameWithOwner}
},... on Issue{id,body,title,updatedAt,createdAt,number,url,state,repository{nameWithOwner}
}
},id,fieldValues(first: 100){nodes{__typename,... on ProjectV2ItemFieldDateValue{date,field{__typename,... on ProjectV2Field{id,name,dataType
},id,
fieldValues(first: 100){nodes{__typename,... on ProjectV2ItemFieldDateValue{date,field{__typename,... on ProjectV2Field{id,name,dataType
},... on ProjectV2IterationField{id,name,dataType
},... on ProjectV2SingleSelectField{id,name,dataType,options{id,name
}
Expand Down
Loading