avaliabrasil/avalia-brasil

Ignore repeating responses

Closed this issue · 3 comments

If a user submits an evaluation to the same place in 24 hours, the api should respond to the android app: "Você já avaliou este local nas últimas 24 horas. Você pode avaliar um estabelecimento no máximo uma vez por dia.", and should not accept another evaluation.

The api is working correctly. The android app should not crash if the api gives this new response on GET /survey and on POST /survey.

The app is still crashing when I try to evaluate a place twice:

10-17 11:49:51.089 13949-13949/org.avaliabrasil.avaliabrasil2 D/AvaliaBrasilAPI: URL: http://api.avaliabrasil.org/survey/ChIJbUVlV2ZpGZURbTOsfSLnn5U
10-17 11:49:51.100 1234-1258/? D/AudioFlinger: mixer(0xaf203b40) throttle end: throttle time(11)
10-17 11:49:51.104 1228-1314/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-17 11:49:51.116 1228-1314/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-17 11:49:51.125 1228-1314/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-17 11:49:51.311 1498-1511/system_process I/ActivityManager: START u0 {cmp=org.avaliabrasil.avaliabrasil2/.avb.activity.EvaluationActivity (has extras)} from uid 10002 on display 0
10-17 11:49:51.434 13949-13949/org.avaliabrasil.avaliabrasil2 D/AndroidRuntime: Shutting down VM

                                                                            --------- beginning of crash

10-17 11:49:51.435 13949-13949/org.avaliabrasil.avaliabrasil2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.avaliabrasil.avaliabrasil2, PID: 13949
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.avaliabrasil.avaliabrasil2/org.avaliabrasil.avaliabrasil2.avb.activity.EvaluationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String, java.lang.String)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String, java.lang.String)' on a null object reference
at org.avaliabrasil.avaliabrasil2.avb.fragments.evaluate.ShareEvaluateFragment.onCreateView(ShareEvaluateFragment.java:60)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:601)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248)
at android.app.Activity.performStart(Activity.java:6681)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

I have checked the api and it's responding correclty:

[
{
"status": 200,
"response": {
"authorized": false,
"error": "Você já avaliou este local nas últimas 24 horas. Você pode avaliar um estabelecimento no máximo uma vez por dia."
}
}
]

Tested, passing.