Skip to content

Commit

Permalink
GQL-20: Creating revisions field for published records (#97)
Browse files Browse the repository at this point in the history
* GQL-20: Saving progress

* GQL-20: Saving progress

* GQL-20: Fixed the revision issue

* GQL-20: Getting tools working with conceptType var

* GQL-20: Var, Services, and Tools all working

* GQL-20: editing var tool and services

* GQL-20: Saving changes

* GQL-20: Var, Tools, and Services using UMM res

* GQL-20: Saving testing progress

* GQL-20: Creating tests

* GQL-20: Collection code in GQL-30 now

* GQL-20: Addressing PR comments for Tool/Var

* GQL-20: addressing pr comments for services

* GQL-20: lint

* GQL-20: Updating based on suggestions

* GQL-20: Making edits

* GQL-20: lint

* GQL-20: Making changes to concept.js

* GQL-20: Saving all passing progress

* GQL-20: making changes as per feedback

* GQL-20: editing for collections

* GQL-20: Adjusting for tests

* GQL-20: addressing comments

* GQL-20: Removing testing changes

* GQL-20: moving comments

---------

Co-authored-by: Deep Mistry <deep.mistry@nasa.gov>
  • Loading branch information
mandyparson and dmistry1 authored Mar 7, 2024
1 parent 90e792e commit ea4de5c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
27 changes: 19 additions & 8 deletions src/cmr/concepts/concept.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export default class Concept {
'sort_key',
'permitted_user',
'include_full_acl',
'all_revisions',
'page_num',
'target'
]
Expand All @@ -284,6 +285,7 @@ export default class Concept {
'concept_id',
'offset',
'page_size',
'all_revisions',
'sort_key'
]
}
Expand Down Expand Up @@ -602,20 +604,24 @@ export default class Concept {

const items = this.parseJsonBody(jsonResponse)

items.forEach((item) => {
items.forEach((item, index) => {
const normalizedItem = this.normalizeJsonItem(item)

const { concept_id: conceptId } = normalizedItem

this.setEssentialJsonValues(conceptId, normalizedItem)
// Creates unique item keys regardless of whether or not
// a user calls for data with similar conceptIds (as is the case with revisions)
const itemKey = `${conceptId}-${index}`

this.setEssentialJsonValues(itemKey, normalizedItem)

jsonKeys.forEach((jsonKey) => {
const cmrKey = snakeCase(jsonKey)

const { [cmrKey]: keyValue } = normalizedItem

// Snake case the key requested and any children of that key
this.setItemValue(conceptId, jsonKey, keyValue)
this.setItemValue(itemKey, jsonKey, keyValue)
})
})
}
Expand All @@ -641,13 +647,18 @@ export default class Concept {

const items = this.parseUmmBody(ummResponse)

items.forEach((item) => {
items.forEach((item, index) => {
const normalizedItem = this.normalizeUmmItem(item)

const { meta } = normalizedItem

const { 'concept-id': conceptId } = meta

this.setEssentialUmmValues(conceptId, normalizedItem)
// Creates unique item keys regardless of whether or not
// a user calls for data with similar conceptIds (as is the case with revisions)
const itemKey = `${conceptId}-${index}`

this.setEssentialUmmValues(itemKey, normalizedItem)

// Loop through the requested umm keys
ummKeys.forEach((ummKey) => {
Expand All @@ -658,7 +669,7 @@ export default class Concept {
// If the raw `ummMetadata` was requested return that value unaltered
if (ummKey === 'ummMetadata') {
this.setItemValue(
conceptId,
itemKey,
ummKey,
keyValue
)
Expand Down Expand Up @@ -694,11 +705,11 @@ export default class Concept {
delete camelCasedObject.previewMetadata.RelatedURLs
}

// Camel case all of the keys of this object (ummKey is already camel cased)
const { [ummKey]: camelCasedValue } = camelCasedObject

// Camel case all of the keys of this object (ummKey is already camel cased)
this.setItemValue(
conceptId,
itemKey,
ummKey,
camelCasedValue
)
Expand Down
2 changes: 2 additions & 0 deletions src/types/collection.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ input CollectionsInput {
version: String
"UMM Variable concept id."
variableConceptId: String
"Returns all revisions when set to true"
allRevisions: Boolean
}

input CollectionInput {
Expand Down
2 changes: 2 additions & 0 deletions src/types/service.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ input ServicesInput {
type: String
"One or more sort keys can be specified to impact searching. Fields can be prepended with a '-' to sort in descending order. Ascending order is the default but + can be used to explicitly request ascending."
sortKey: String
"Returns all revisions when set to true"
allRevisions: Boolean
}

input ServiceInput {
Expand Down
4 changes: 3 additions & 1 deletion src/types/tool.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ input ToolsInput {
provider: String
"One or more sort keys can be specified to impact searching. Fields can be prepended with a '-' to sort in descending order. Ascending order is the default but + can be used to explicitly request ascending."
sortKey: String
"Returns all revisions when set to true"
allRevisions: Boolean
}

input ToolInput {
Expand Down Expand Up @@ -147,4 +149,4 @@ type ToolMutationResponse {
conceptId: String!
"The revision of the tool."
revisionId: String!
}
}
2 changes: 2 additions & 0 deletions src/types/variable.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ input VariablesInput {
provider: String
"One or more sort keys can be specified to impact searching. Fields can be prepended with a '-' to sort in descending order. Ascending order is the default but + can be used to explicitly request ascending."
sortKey: String
"Returns all revisions when set to true"
allRevisions: Boolean
}

input VariableInput {
Expand Down

0 comments on commit ea4de5c

Please sign in to comment.