Closed bbest closed 2 years ago
report-v2
operationsget_{content}_tbl()
functionsd_pubs_tags
dataTableOutput("tbl_pubs")
output$tbl_pubs <- renderDataTable({ get_pubs() ... })
get_pubs <- reactive({ get_pubs_tbl(d_pubs_tags, ixns = values$ixns) })
get_pubs_tbl()
tag_cats <- get_content_tag_categories("publications")
get_rowids_with_ixn(ixns, db_tbl = "tethys_pub_tags", categories = tag_cats)
get_rowids_with_ixn()
# subset interactions by categories available to content type
d_pubs_tags
does not have Stressor.Noise.Underwater
or any Stressor.Noise.*
children.You'll probably want to use direct SQL, ie DBI::getQuery()
to take advantage of the Postgres ltree querying to ask whether any children exist. Here's some further reference:
ltree: store tags as hierarchically labelled tree in postgres · Issue #17 · marineenergy/apps
show existing d_pubs_tags
as SQL:
d_pubs_tags %>% dplyr::show_query()
shows:
SELECT DISTINCT "rowid", "uri", "title", "tag", "tag_category", "tag_sql"
FROM (
SELECT "LHS"."rowid" AS "rowid", "uri", "title", "tag", "tag_category", "tag_sql"
FROM (
SELECT "rowid", "uri", "title"
FROM "tethys_pubs") "LHS"
LEFT JOIN (
SELECT "tag", "rowid", "tag_category", "tag_sql"
FROM "tethys_pub_tags") "RHS"
ON ("LHS"."rowid" = "RHS"."rowid")
Pseudocode:
# if "Stressor.Noise.Underwater" not in "tethys_pub_tags" & has level > 2
# then check if higher level exists. if so, update to that one and share message
Trick:
dput(ixns) # to output variable
Cristina's current approach:
The problem currently is that per https://github.com/marineenergy/apps/issues/106#issuecomment-1015582361 we need both of these intxns
filtering processes to happen per content type, ideally with messages back to the user:
Drop non-applicable tag categories, ie dropping Consequence.Collision
tag from interactions querying Publications since this content type lacks the Consequence
category; and
Convert missing child tags to parents, ie converting Stressor.Noise.Underwater
to Stressor.Noise
with Publications since this content type only has the parent Noise tag.
# get ixns by content type
ixns_pubs <– get_ixns_for_content(ixns, "publications") # add attributes with messages
# get data, ie rows, of content by ixns
rowids <- sapply(ixns_pubs, get_rowids_with_ixn, db_tbl = "tethys_pub_tags", categories = tag_cats) %>%
unlist() %>% unique()
d <- d %>%
filter(rowid %in% !!rowids)
And still need to produce an output in server.R
per content type like:
Tags with non-applicable tag categories are now dropped from interactions, but messages demonstrating modifications to missing child tags are now appearing even when there is a NULL message attribute in the corresponding data.
When Noise/Underwater and Fish/DemersalFish are selected, the message on the Publications page appears as expected:
However, there is a message on both the Documents and Management pages, even though there is data to match the tags in the interaction. This message should not appear at all, but instead it appears as follows:
Looks like this is working fine with latest overhaul
Problem
From MarineEnergy.app_Review_GCS_120921.docx - Google Docs:
Update filter for content based on available tags
Noise/Underwater
Noise/Underwater
got replaced by parent tag StressorNoise
in filter since tagging in Publications did not resolve to StressorNoise/Underwater
Message based on content
A la https://github.com/marineenergy/apps/issues/93: