Giter Club home page Giter Club logo

ud858's Introduction

ud858

Course code for Building Scalable Apps with Google App Engine in Python class

Archival Note

This repository is deprecated; therefore, we are going to archive it. However, learners will be able to fork it to their personal Github account but cannot submit PRs to this repository. If you have any issues or suggestions to make, feel free to:

ud858's People

Contributors

adarsh0806 avatar jeffudacity avatar karlud avatar pmallory avatar qgreg avatar richgieg avatar sudkul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ud858's Issues

Endpoints API not loading soon enough?

When the Conference app web page is refreshed at the /#/conference link, the endpoints API query fails due to the queryConferences endpoint method not being initialized. After the page is loaded, clicking on a different tab works fine, and then clicking on the "All" tab works.

The error is

TypeError: Cannot read property 'queryConferences' of undefined  at  angular.js:9778

It seems the bootstrapping method for loading the google API does complete in time if the initial page being loaded makes an endpoints API call.

"Registered" value inaccurate on conference details page after unregistering

Problem

  1. User navigates to the details page for a conference, in this example conference.maxAttendees is 3 (Registered/Open: 0/3)
  2. User registers for the conference (Registered/Open: 1/3)
  3. User navigates to another page on the site
  4. User navigates back to the details page for the same conference (Registered/Open: 1/3)
  5. User unregisters from the conference (Registered/Open: -18/3)

Analysis

The getConference API endpoint returns a ConferenceForm object in which all IntegerField values are actually encoded as strings (wrapped in double quotes), as opposed to integers (no double quotes). This encoding is performed by an internal Google Endpoints method called EndpointsProtoJson.encode_field which is executed during the JSON-encoding process. Due to the integers being encoded as strings in the returned JSON, conference.seatsAvailable (in controller.js) ends up pointing to a string object that represents the number of seats available in the conference, rather than a number object. When the controller.js function unregisterFromConference function gets called, it attempts to add the number 1 to conference.seatsAvailable, but instead the number 1 is converted to a string and concatenated onto the end. In step 5 of the above problem statement, conference.seatsAvailable would point to the string '21' (the concatenation of the string '2' and the number 1). This causes the calculation in conference_detail.html, conference.maxAttendees - conference.seatsAvailable to yield the result -18, instead of the intended 3. The subtraction operator causes both operands to be converted to number objects, then the subtraction is carried out, whereas the addition operator in unregisterFromConference is interpreted as a concatenation operator. If steps 3 and 4 in the above problem statement are skipped, the correct result would be displayed. This is because step 2 causes the controller.js function registerForConference to execute, which subtracts 1 from conference.seatsAvailable thus converting it from a string object to a number object prior to step 5 executing. In this instance, the addition operator does not get interpreted as the concatenation operator because neither of the operands is a string. The addition is then carried out and the correct result displayed.

Solution

A solution to this type of problem is to add a keyword argument called variant with a value of messages.Variant.INT32 to the IntegerField constructor calls in the ConferenceForm class definition in models.py. This prevents the integer values from being wrapped in double quotes in the JSON returned by the API, thus ensuring the values are represented properly in the front-end JavaScript code. As a result, all calculations yield the intended results.

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.