mozilla / kitsune

Platform for Mozilla Support
https://mozilla.github.io/kitsune/
BSD 3-Clause "New" or "Revised" License
1.32k stars 726 forks source link

API returning incorrect times (e.g., created, updated) #3686

Closed jscher2000 closed 5 years ago

jscher2000 commented 5 years ago

I have a "My Questions" tool (https://github.com/jscher2000/My-SuMo-Questions) that retrieves the following URL (of course, you would supply your own SuMo username):

https://support.mozilla.org/api/2/question/?format=json&ordering=-updated&is_spam=False&involved=jscher2000&page=1

The feed provides UTC date-time values such as:

"updated": "2019-05-27T08:17:11Z"

However, at some point between May 17 and May 24 the time stamps started returning Pacific time instead of UTC. The above thread was updated at 8:17am Pacific Daylight Savings time, so the correct UTC time should have been 7 hours later.

There is a similar problem with "created" and "updated" values in:

https://support.mozilla.org/api/2/answer/?format=json&question=1260189&is_spam=False&ordering=id

Other properties might also be affected.

rtanglao commented 5 years ago

i have reproduced this issue:

rtanglao commented 5 years ago

still have this problem, could we please fix this in q4 @madasan ?

rtmba:rt-kitsune-api rolandtanglao$ ./testAPI-issue-3686.rb

output:

integer time in API:1557734020
integer time in SUMO website:1557759220
TEST FAILED! Difference in seconds sumo time - api time:25200
TEST FAILED! Difference in hours:7

code is here: https://github.com/rtanglao/rt-kitsune-api/blob/master/testAPI-issue-3686.rb

rtanglao commented 5 years ago

@akatsoulas this bug affects our firefox dashboard (confirmed by @ophie200 aka nancy wong! so i believe this upgrades the severity of to MUST from would be nice. Do you agree @madasan ?

madasan commented 5 years ago

Sounds like a P1 to me, indeed. @akatsoulas let's see when we can fit it in.

rtanglao commented 5 years ago

this issue has a non public jira which is basically a jira to re-read the data when this is fixed: https://jira.mozilla.com/browse/DA-1438

akatsoulas commented 5 years ago

This is fixed in pr #3910. I will close the issue once it's released in prod.

rtanglao commented 5 years ago

i tested this and it works on staging!

https://github.com/rtanglao/rt-kitsune-api/blob/master/staging-testAPI-issue-3686.rb

./staging-testAPI-issue-3686.rb

output:

{
                "answers" => [],
                "content" => "<p>testjkknkjn\n</p>",
                "created" => "2019-10-04T09:41:37Z",
                "creator" => {
            "username" => "roxanaleitan",
        "display_name" => "roxana admin",
              "avatar" => "https://firefoxusercontent.com/00000000000000000000000000000000"
    },
                     "id" => 1207006,
               "involved" => [
        [0] {
                "username" => "roxanaleitan",
            "display_name" => "roxana admin",
                  "avatar" => "https://firefoxusercontent.com/00000000000000000000000000000000"
        }
    ],
            "is_archived" => false,
              "is_locked" => false,
              "is_solved" => false,
                "is_spam" => false,
               "is_taken" => false,
            "last_answer" => nil,
                 "locale" => "en-US",
               "metadata" => [
        [0] {
             "name" => "category",
            "value" => "download-and-install"
        },
        [1] {
             "name" => "ff_version",
            "value" => "69.0"
        },
        [2] {
             "name" => "os",
            "value" => "Windows 10"
        },
        [3] {
             "name" => "plugins",
            "value" => "* Shockwave Flash 32.0 r0"
        },
        [4] {
             "name" => "product",
            "value" => "desktop"
        },
        [5] {
             "name" => "useragent",
            "value" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"
        }
    ],
                   "tags" => [
        [0] {
            "name" => "download-and-install",
            "slug" => "download-and-install_1"
        },
        [1] {
            "name" => "Firefox 69.0",
            "slug" => "firefox-690"
        },
        [2] {
            "name" => "desktop",
            "slug" => "desktop"
        },
        [3] {
            "name" => "Windows 10",
            "slug" => "windows-10"
        }
    ],
            "num_answers" => 0,
    "num_votes_past_week" => 0,
              "num_votes" => 1,
                "product" => "firefox",
               "solution" => nil,
              "solved_by" => nil,
            "taken_until" => nil,
               "taken_by" => nil,
                  "title" => "test roxana",
                  "topic" => "download-and-install",
             "updated_by" => nil,
                "updated" => "2019-10-04T09:41:37Z"
}
"2019-10-04T09:41:37Z"
integer time in API:1570182097
integer time in SUMO website:1570182097
TEST PASSED
akatsoulas commented 5 years ago

This is live in prod.

rtanglao commented 5 years ago

verified that this works in production! thanks @akatsoulas

test run of testAPI-issue-3686.rb :

./testAPI-issue-3686.rb 

test output:

{
                "answers" => [
        [ 0] 1222018,
        [ 1] 1222044,
        [ 2] 1222056,
        [ 3] 1222067,
        [ 4] 1222070,
        [ 5] 1222071,
        [ 6] 1222125,
        [ 7] 1222128,
        [ 8] 1222302,
        [ 9] 1222414,
        [10] 1222423,
        [11] 1225628
    ],
                "content" => "<p>Morning,\n</p><p>I've recently switched back to Firefox (for Mac) after being away from Ff for a long time, and have been tinkering with my settings and whatnot to try and get things the way I would like them. I suspect, like most things, that I'm just missing something. ;-)\n</p><p>Basically, I don't want Ff to remember any autofill//form information, and I've got that working, but I would like it to be able to respect when a website allows you to click a radio button for \"Remember &lt;Me//This//Etc&gt;\". It does not seem to be doing that at the moment.\n</p><p>Does Ff have a setting that will let websites that you specifically click \"Remember Me\" be remembered, or is it an all or nothing?\n</p><p>Thanks!\n</p>",
                "created" => "2019-05-13T14:53:40Z",
                "creator" => {
            "username" => "mattagc",
        "display_name" => nil,
              "avatar" => "https://secure.gravatar.com/avatar/f0e4c5328a02ad72767fc75385052804?s=48&d=https%3A//static-media-prod-cdn.itsre-sumo.mozilla.net/static/sumo/img/avatar.png"
    },
                     "id" => 1259114,
               "involved" => [
        [0] {
                "username" => "jscher2000",
            "display_name" => "jscher2000",
                  "avatar" => "https://firefoxusercontent.com/4c7c89d3462af52bac94074246fd5e98"
        },
        [1] {
                "username" => "mattagc",
            "display_name" => nil,
                  "avatar" => "https://secure.gravatar.com/avatar/f0e4c5328a02ad72767fc75385052804?s=48&d=https%3A//static-media-prod-cdn.itsre-sumo.mozilla.net/static/sumo/img/avatar.png"
        },
        [2] {
                "username" => "cor-el",
            "display_name" => "",
                  "avatar" => "https://firefoxusercontent.com/f369028d14003acbf4f1a9ed0debb2c8"
        }
    ],
            "is_archived" => false,
              "is_locked" => false,
              "is_solved" => false,
                "is_spam" => false,
               "is_taken" => false,
            "last_answer" => 1225628,
                 "locale" => "en-US",
               "metadata" => [
        [0] {
             "name" => "category",
            "value" => "privacy-and-security"
        },
        [1] {
             "name" => "ff_version",
            "value" => "66.0"
        },
        [2] {
             "name" => "os",
            "value" => "Mac OS"
        },
        [3] {
             "name" => "plugins",
            "value" => "* Shockwave Flash 32.0 r0"
        },
        [4] {
             "name" => "product",
            "value" => "desktop"
        },
        [5] {
             "name" => "useragent",
            "value" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0"
        }
    ],
                   "tags" => [
        [0] {
            "name" => "Firefox 66.0",
            "slug" => "firefox-660"
        },
        [1] {
            "name" => "privacy-and-security",
            "slug" => "privacy-and-security_1"
        },
        [2] {
            "name" => "desktop",
            "slug" => "desktop"
        },
        [3] {
            "name" => "Mac OS",
            "slug" => "mac-os"
        }
    ],
            "num_answers" => 12,
    "num_votes_past_week" => 0,
              "num_votes" => 1,
                "product" => "firefox",
               "solution" => nil,
              "solved_by" => nil,
            "taken_until" => nil,
               "taken_by" => nil,
                  "title" => "Firefox doesn't seem to be allowing websites to \"remember <random thing>\".",
                  "topic" => "privacy-and-security",
             "updated_by" => nil,
                "updated" => "2019-05-28T02:18:25Z"
}
"2019-05-13T14:53:40Z"
integer time in API:1557759220
integer time in SU
jscher2000 commented 5 years ago

Thanks everyone!

jscher2000 commented 5 years ago

Okay, sorry, but the updated__gt parameter appears to expect PDT instead of UTC. New issue?

Could it be related to this discrepancy -- I only use updated__gt with questions, not answers:

class QuestionFilter(django_filters.FilterSet):

updated = django_filters.DateTimeFilter()
created = django_filters.DateTimeFilter()

class AnswerFilter(django_filters.FilterSet):

updated = django_filters.IsoDateTimeFilter()
created = django_filters.IsoDateTimeFilter()
rtanglao commented 5 years ago

new issue please @jscher2000 !

jscher2000 commented 5 years ago

new issue please @jscher2000 !

Okay: https://github.com/mozilla/kitsune/issues/3946

rtanglao commented 1 year ago