Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined functionality to schedule and complete ad-hoc observation into one endpoint #2697

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tommylau523
Copy link
Contributor

No description provided.

@tommylau523 tommylau523 marked this pull request as ready for review December 13, 2024 22:52
@tommylau523 tommylau523 requested a review from a team as a code owner December 13, 2024 22:52
Copy link
Contributor Author

tommylau523 commented Dec 13, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@@ -408,38 +412,56 @@ class ObservationService(
}

/**
* Schedule an ad-hoc observation. This creates an ad-hoc observation, creates an ad-hoc
* monitoring plot, and adds the plot to the observation.
* Record an ad-hoc observation. This creates an ad-hoc observation, creates an ad-hoc monitoring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: KDoc convention, which was inherited from Javadoc, is to use singular present tense. So this would be "Records" instead of "Record" (and "completes" instead of "complete" on the next line).

observationType: ObservationType,
plantingSiteId: PlantingSiteId,
plants: Collection<RecordedPlantsRow>,
plotName: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that plot names are going away shortly, so we shouldn't build new client code that expects to be able to pass in a user-supplied name. (But removing this parameter isn't appropriate yet since names still exist for now.)

swCorner: Point,
): Pair<ObservationId, MonitoringPlotId> {
requirePermissions { scheduleAdHocObservation(plantingSiteId) }

validateSchedule(plantingSiteId, startDate, endDate)
if (observedTime.isAfter(clock.instant())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to reject wildly wrong timestamps, but I'm concerned this check will be sensitive to clock skew and will reject legitimate observations where the user's phone clock is ahead of the server's clock by a small amount.

Comment on lines +552 to +554
* Validation rules: 1a. for non-ad-hoc, start date can be up to one year from today and not
* earlier than today. 1b. for ad-hoc, start date can be on or before today.
* 2. end date should be after the start date but no more than 2 months from the start date.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "1a" and "1b" are confusing the formatter because they're not valid Markdown list item numbers.

plantCountsBySpecies,
)
}

updateSpeciesTotalsTable(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verifying the intent here: we want to update the site-level species totals based on ad-hoc observations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants