Code Monkey home page Code Monkey logo

Comments (3)

jwalgran avatar jwalgran commented on July 27, 2024

The surveys listed in the attached spreadsheet back to May 2015, so we can be fairly confident that whatever is going on is not related to recent changes in the application.

There is only once place in the code where new surveys are created, and if the mapper reaches the final preview page with the “Does this look right?” message then the survey must have been saved and the is_available field on the associated block edge must have been set to False.

@transaction.atomic
def _create_survey_and_trees(request, event=None):
"""
Creates survey and trees from JSON body, where k1... are model attrs: {
survey: { k1:v1, ... },
trees: [
{ k1:v1, ...},
...
]
}
trees.problems should be a list of problem codes -- ["Stones", "Sneakers"]
"""
survey, tree_list = _get_survey_data(request)
blockface = survey.blockface
if event:
territory = _get_territory(blockface)
if territory is None or territory.group_id != event.group_id:
return HttpResponseForbidden(
"Blockface is not in group's territory.")
else:
if not _query_reservation(request.user, blockface.id).exists():
return HttpResponseForbidden(
'You have not reserved this block edge.')
survey.full_clean()
survey.save()
_mark_survey_blockface_availability(survey, False)

If the mapper taps “No, Restart” from the final preview, and then taps “Restart” (or possibly double-taps on “No, Restart”) then the application, by design, updates the blockface record to set is_available back to True.

def restart_blockface(request, survey_id):
survey = get_object_or_404(Survey, id=survey_id, user=request.user)
survey.submit_comment = request.POST.get('comment', '')
survey.full_clean()
survey.save()
_mark_survey_blockface_availability(survey, True)
expiration_date = now() + settings.RESERVATION_TIME_PERIOD
BlockfaceReservation.objects.create(blockface=survey.blockface,
user=request.user,
expires_at=expiration_date)
return {'success': True}

from nyc-trees.

jwalgran avatar jwalgran commented on July 27, 2024

Do we have any information on when the blockface is flipping back to available? Do we know if it is immediately after the survey is submitted, or sometime later?

It’s immediate, or put another way, the problem is that the blocks are never flipping to not available, so immediately after someone completes a survey they look at the map and the block they just did is still open.

It is “good” that it is happening immediately. That behavior matches the way the code is structured.

  • The Mapper submits a survey
  • The App saves a new survey row to the database and sets is_available on the blockface to False within the same database transaction.
  • The App shows the output of the geometry constructor and presents 3 options
    • If the Mapper taps “Yes,” the App just redirects to the survey page.
    • If the Mapper taps “No, Restart” and then taps “Restart” (or possibly double-taps “No, Restart” since the buttons are in the same location and the associated text box does not require content) the App updates the blockface to set is_available back to True and redirects to the survey page.
    • If the Mapper taps “No, Submit for Review” then enters a message and taps “Submit for Review” the App updates the survey to set is_flagged to True and leaves is_available set to False on the blockface.
      If “No, Restart” is tapped by mistake, there is no way to go back and choose another option. The Mapper has to tap “Restart” to get back to the survey page, which sets is_available on the blockface back to True.

from nyc-trees.

jwalgran avatar jwalgran commented on July 27, 2024

Closing for now because:

  • It cannot be reliably recreated in staging.
  • The problem is not a recent regression
  • Code auditing shows that block availability is only changed in 2 places, to False when a survey is submitted and to True when a survey is restarted.

If we want to dig into this further, we could make it required for users to complete the "why do you want to restart" box that appears after clicking "no, restart." That would likely serve as a check when people hit the restart button accidentally and potentially reduce the number of unintended multiple surveys.

from nyc-trees.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.