Skip to content

Commit

Permalink
Merge pull request #1412 from dpc-sdp/feature/grants-improvements
Browse files Browse the repository at this point in the history
[SD-519] grants improvements
  • Loading branch information
lambry authored Dec 18, 2024
2 parents 0fa76b8 + 4e4dbed commit 937003b
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 97 deletions.
20 changes: 11 additions & 9 deletions examples/nuxt-app/test/features/search-listing/grants.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ Feature: Grants collection
And the search network request is stubbed with fixture "/search-listing/grants/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"
When I visit the page "/grants"
Then the search listing page should have 3 results
Then the search listing page should have 5 results
And the search listing layout should be "list"
And the search network request should be called with the "/search-listing/grants/request" fixture
And the grant search listing results should have following items:
| title | url | updated | content | audience | amount | status |
| THIS IS A TEST | /tc-9b-grant-page-closed | Updated: 9 May 2023 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus. | Business | $11,326 - $26,494 | Closed |
| TC-9a Grant Simple Test - Date Range | /tc-9a-grant-simple-test-date-range | Updated: 9 May 2023 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus. | Not-for-profit groups, government | $11,326 - $26,494 | Open, closing in 163 days |
| 2023 Coastcare Victoria Community Grants | https://www.marineandcoasts.vic.gov.au/coastcare-victoria-community-grants | Updated: 8 March 2023 | This year, Coastcare Victoria has $210,000 available for grants of up to $10,000 each. Projects will fit into one of three streams on offer including | Who can apply:Individuals, not-for-profit groups | $1 - $10,000 | Closed |
| title | url | content | audience | amount | status |
| THIS IS A TEST | /tc-9b-grant-page-closed | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus. | Business | $11,326 - $26,494 | Closed |
| TC-9a Grant Simple Test - Date Range | /tc-9a-grant-simple-test-date-range | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus. | Not-for-profit groups, government | $11,326 - $26,494 | Open, closes 16 July 2050 |
| 2023 Coastcare Victoria Community Grants | https://www.marineandcoasts.vic.gov.au/coastcare-victoria-community-grants | This year, Coastcare Victoria has $210,000 available for grants of up to $10,000 each. Projects will fit into one of three streams on offer including | Who can apply:Individuals, not-for-profit groups | $1 - $10,000 | Closed |
| Opening soon test | /opening-soon-test | Supporting schools to build strong VCE Vocational Major and Victorian Pathways Certificate delivery | Government schools | $0 - $30,000 | Opens 16 April 2050 |
| Youth Access Initiative | /youth-access-initiative | The Youth Access Initiative provides young people who have care and/or youth justice experience or who are residing in Education First Youth Foyers | Individuals | | Ongoing |

@mockserver
Example: Grant status filter - Open
Given the page endpoint for path "/grants" returns fixture "/search-listing/grants/page" with status 200
And the search network request is stubbed with fixture "/search-listing/grants/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"
When I visit the page "/grants?status=open"
Then the search listing page should have 3 results
Then the search listing page should have 5 results
And the search network request should be called with the "/search-listing/grants/request-status-open" fixture

@mockserver
Expand All @@ -37,7 +39,7 @@ Feature: Grants collection
And the search network request is stubbed with fixture "/search-listing/grants/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"
When I visit the page "/grants?status=closed"
Then the search listing page should have 3 results
Then the search listing page should have 5 results
And the search network request should be called with the "/search-listing/grants/request-status-closed" fixture

@mockserver
Expand All @@ -46,7 +48,7 @@ Feature: Grants collection
And the search network request is stubbed with fixture "/search-listing/grants/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"
When I visit the page "/grants?status=ongoing"
Then the search listing page should have 3 results
Then the search listing page should have 5 results
And the search network request should be called with the "/search-listing/grants/request-status-ongoing" fixture

@mockserver
Expand All @@ -55,5 +57,5 @@ Feature: Grants collection
And the search network request is stubbed with fixture "/search-listing/grants/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"
When I visit the page "/grants?status=opening_soon"
Then the search listing page should have 3 results
Then the search listing page should have 5 results
And the search network request should be called with the "/search-listing/grants/request-status-opening-soon" fixture
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
}
}
}
],
"must_not": [
{
"term": {
"field_node_on_going": "true"
}
}
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"hits": {
"total": {
"value": 2,
"value": 5,
"relation": "eq"
},
"max_score": null,
Expand Down Expand Up @@ -184,6 +184,87 @@
"uuid": ["e8022205-e15f-4231-ac38-49ed14328823"]
},
"sort": [1.0, 3522]
},
{
"_index": "a83890f7a31dea14e1ae83c6f0afacca--elasticsearch_index_develop_node",
"_id": "entity:node/45297:en",
"_score": 2.0,
"_source": {
"_language": "en",
"node_grants": ["node_access_all:0"],
"url": ["/site-4/opening-soon-test"],
"changed": ["2024-12-13T15:03:02+11:00"],
"created": ["2024-12-13T15:01:54+11:00"],
"field_audience": [2128],
"field_audience_name": ["Government schools"],
"field_audience_uuid": ["b753188a-fa7c-4252-bc5e-3d60d242a36d"],
"field_content_category": [1317],
"field_content_category_name": ["Program"],
"field_landing_page_intro_text": [
"Supporting schools to build strong VCE Vocational Major and Victorian Pathways Certificate delivery"
],
"field_landing_page_summary": [
"Supporting schools to build strong VCE Vocational Major and Victorian Pathways Certificate delivery"
],
"field_node_dates_end_value": ["2050-12-16T00:00:00+10:00"],
"field_node_dates_start_value": ["2050-04-16T18:00:00+10:00"],
"field_node_on_going": [false],
"field_node_primary_csite": [4],
"field_node_site": [4, 842],
"field_topic": [10],
"field_topic_name": ["Education"],
"field_topic_path": ["/topic/education"],
"field_topic_uuid": ["3764c1dc-9475-43cc-a483-96bec239c4f7"],
"funding_level_from": [0],
"funding_level_to": [30000],
"langcode": ["en"],
"nid": [45297],
"status": [true],
"title": ["Opening soon test"],
"type": ["grant"],
"uid": [11836],
"uuid": ["f46e3c08-3dc5-4791-8494-9d3d6955441c"]
},
"sort": [2.0, 1798549200000, "Opening soon test"]
},
{
"_index": "a83890f7a31dea14e1ae83c6f0afacca--elasticsearch_index_production_node",
"_id": "entity:node/24378:en",
"_score": 1.0,
"_source": {
"_language": "en",
"node_grants": ["node_access_all:0"],
"url": ["/site-4/youth-access-initiative"],
"changed": ["2023-09-28T15:52:24+10:00"],
"created": ["2022-03-28T16:47:53+11:00"],
"field_audience": [80],
"field_audience_name": ["Individual"],
"field_audience_uuid": ["f86a3a17-380b-4840-8d54-195260ac9db1"],
"field_content_category": [1318, 1317],
"field_content_category_name": ["Initiative", "Program"],
"field_landing_page_contact_name": ["The Skills First team"],
"field_landing_page_intro_text": [
"The Youth Access Initiative provides young people who have care and/or youth justice experience or who are residing in Education First Youth Foyers with access to vocational education and training opportunities through a tuition fee waiver."
],
"field_landing_page_summary": [
"The Youth Access Initiative provides young people who have care and/or youth justice experience or who are residing in Education First Youth Foyers with access to vocational education and training opportunities through a tuition fee waiver."
],
"field_node_on_going": [true],
"field_node_primary_csite": [4],
"field_node_site": [1036, 4],
"field_topic": [10],
"field_topic_name": ["Education"],
"field_topic_path": ["/topic/education"],
"field_topic_uuid": ["3764c1dc-9475-43cc-a483-96bec239c4f7"],
"langcode": ["en"],
"nid": [24378],
"status": [true],
"title": ["Youth Access Initiative"],
"type": ["grant"],
"uid": [9920],
"uuid": ["a9b548ec-f44b-48eb-8407-21cf7e6ef4ed"]
},
"sort": [1.0, "Youth Access Initiative"]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Then(
cy.get('@meta').should('contain', row.amount)
cy.get('@meta').should('contain', row.status)
cy.get('@item').should('contain', row.content)
cy.get('@item').should('contain', row.updated)
if (row.updated) {
cy.get('@item').should('contain', row.updated)
}
})
})
}
Expand Down
97 changes: 97 additions & 0 deletions packages/ripple-tide-grant/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export default defineAppConfig({
}
}
}
],
must_not: [
{
term: {
field_node_on_going: 'true'
}
}
]
}
}
Expand Down Expand Up @@ -65,6 +72,96 @@ export default defineAppConfig({
}
}
}
},
queryConfigFunctions: {
grantsQueryFn: ({ queryFilters, searchTerm }) => {
const searchQuery = searchTerm?.q
? {
multi_match: {
query: searchTerm?.q,
fields: [
'title^3',
'field_landing_page_summary^2',
'body',
'field_paragraph_body',
'summary_processed'
]
}
}
: [{ match_all: {} }]

const rangeQuery = [
{
range: {
field_node_dates_start_value: {
lte: 'now'
}
}
},
{
range: {
field_node_dates_end_value: {
gte: 'now'
}
}
}
]

return {
function_score: {
query: {
bool: {
must: searchQuery,
filter: queryFilters
}
},
functions: [
{
filter: {
bool: {
must: [
...rangeQuery,
{ term: { field_node_on_going: false } }
]
}
},
weight: 4
},
{
filter: {
bool: {
must: [...rangeQuery],
must_not: [{ exists: { field: 'field_node_on_going' } }]
}
},
weight: 4
},
{
filter: [
{
term: { field_node_on_going: true }
}
],
weight: 3
},
{
filter: [
{
range: {
field_node_dates_start_value: {
gte: 'now'
}
}
}
],
weight: 2
}
],
score_mode: 'sum',
boost_mode: 'multiply'
}
}
}
}
}
}
Expand Down
34 changes: 23 additions & 11 deletions packages/ripple-tide-grant/components/TideGrantMeta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ const grantStatus = computed(() => {
const overviewList = computed(() => {
let list: any[] = []
const icons = {
open: {
name: 'icon-check-circle-filled',
color: 'success'
},
closed: {
name: 'icon-cancel-circle-filled',
color: 'error'
},
opening_soon: {
name: 'icon-clock-circle-filled',
color: 'warning'
}
}
list.push({
term: 'Status:',
description: grantStatus.value.displayLabel,
iconName:
icons[grantStatus.value.status]?.name || 'icon-info-circle-filled',
iconColour: icons[grantStatus.value.status]?.color || 'default'
})
if (props.audience) {
list.push({
term: 'Who can apply:',
Expand All @@ -39,17 +62,6 @@ const overviewList = computed(() => {
})
}
const open =
grantStatus.value.status === 'open' ||
grantStatus.value.status === 'opening_soon'
list.push({
term: 'Status:',
description: grantStatus.value.displayLabel,
iconName: open ? 'icon-check-circle-filled' : 'icon-cancel-circle-filled',
iconColour: open ? 'success' : 'error'
})
if (props.funding) {
list.push({
term: 'Funding:',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const link = computed(() => {
:title="title"
:url="link"
:content="summary"
:updated="updated"
>
<template #details>
<TideGrantMeta
Expand Down
Loading

0 comments on commit 937003b

Please sign in to comment.