Skip to content

Commit

Permalink
Merge pull request #854 from jembi/ocrvs-1673-landing-page
Browse files Browse the repository at this point in the history
hot fixes for QA
  • Loading branch information
euanmillar authored Jun 17, 2019
2 parents 9da78df + 969e4b2 commit 8e13b81
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 39 deletions.
10 changes: 8 additions & 2 deletions packages/register/src/views/RegistrarHome/RegistrarHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ export class RegistrarHomeView extends React.Component<
'',
application_time_elapsed:
(reg.createdAt &&
moment(reg.createdAt.toString(), 'YYYY-MM-DD').fromNow()) ||
moment(
moment(reg.createdAt, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()) ||
'',
actions
}
Expand Down Expand Up @@ -365,7 +368,10 @@ export class RegistrarHomeView extends React.Component<
...reg,
date_of_rejection:
(reg.modifiedAt &&
moment(reg.modifiedAt.toString(), 'YYYY-MM-DD').fromNow()) ||
moment(
moment(reg.modifiedAt, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()) ||
'',
actions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const ErrorText = styled.div`
color: ${({ theme }) => theme.colors.error};
${({ theme }) => theme.fonts.bodyStyle};
text-align: center;
margin-top: 100px;
margin: 25px;
`

function LabelValue({ label, value }: { label: string; value: string }) {
Expand Down
92 changes: 58 additions & 34 deletions packages/search/src/elasticsearch/dbhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,75 @@ export const indexComposition = async (
compositionIdentifier: string,
body: ICompositionBody
) => {
const response = await client.index({
index: 'ocrvs',
type: 'compositions',
id: compositionIdentifier,
body
})
try {
const response = await client.index({
index: 'ocrvs',
type: 'compositions',
id: compositionIdentifier,
body
})

return response
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
throw err
}
}

export const updateComposition = async (id: string, body: ICompositionBody) => {
const response = await client.update({
index: 'ocrvs',
type: 'compositions',
id,
body: {
doc: body
}
})
try {
const response = await client.update({
index: 'ocrvs',
type: 'compositions',
id,
body: {
doc: body
}
})

return response
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
throw err
}
}

export const searchComposition = async (body: ICompositionBody) => {
const response = client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: buildQuery(body)
}
})
return response
try {
const response = client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: buildQuery(body)
}
})
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
return null
}
}

export const searchByCompositionId = async (compositionId: string) => {
const response = await client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: {
match: {
_id: compositionId
try {
const response = await client.search({
index: 'ocrvs',
type: 'compositions',
body: {
query: {
match: {
_id: compositionId
}
}
}
}
})
return response
})
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
return null
}
}
5 changes: 3 additions & 2 deletions packages/search/src/elasticsearch/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function detectDuplicates(
export async function getCreatedBy(compositionId: string) {
const results = await searchByCompositionId(compositionId)
const result =
results &&
results.hits.hits &&
(results.hits.hits[0] && (results.hits.hits[0]._source as ICompositionBody))

Expand All @@ -78,9 +79,9 @@ export async function getCreatedBy(compositionId: string) {

function findDuplicateIds(
compositionIdentifier: string,
results: SearchResponse<{}>
results: SearchResponse<{}> | null
) {
const hits = results.hits.hits
const hits = (results && results.hits.hits) || []
return hits
.filter(
hit =>
Expand Down

0 comments on commit 8e13b81

Please sign in to comment.