Skip to content

Best way to detect and then delete datastreams that have no observations? #1572

Answered by hylkevds
ssoper-usgs asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, $top=1 is faster than $count. FROST-Manager has a cleanup tool that does:

EntityList<Datastream> list = service.datastreams()
                .query()
                .select("name", "id")
                .expand("Observations($select=id;$top=1)")
                .orderBy("id asc")
                .list();

So instead of fetching individual Datastreams/Observations it fetches Datastreams and expands Observations. That way it only needs one call per Datastream-page. It then deletes the Datastreams with no Observations.

Can you check what the value is for the Datastream.phenomenonTime for those empty Datastreams? If the trigger works correctly, then that should be empty. That may be an…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hylkevds
Comment options

Answer selected by ssoper-usgs
@ssoper-usgs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants