Refactor link/reply data structure #8

Open
opened 2019-11-21 13:20:32 +00:00 by cmccabe · 2 comments
Owner

Initial data model is not integrated and easy to use. Refactor into a more standard model.

Initial data model is not integrated and easy to use. Refactor into a more standard model.
cmccabe added the
future release
label 2019-11-21 13:20:32 +00:00
Collaborator

The structure suggested by Sloum was:

links = {
    "category1": [
        {
            "title": "Tildegit",
            "link": "https://tildegit.org",
            "user": "sloum",
            "time": 1574641578,
            "replies": [
                {"user": "asdf", "time": 1574328572, "reply": "Me too!"},
                {"user": "cmccabe", "time": 1575528561, "reply": "Me three!"}
            ]
        }
    ],
    "other category": [
        {
            "title": "Stuff",
            "link": "https://blah.com",
            "user": "someuser",
            "time": 1574641578,
            "replies": []
        }
    ]
}

I like this approach. Using a class or named tuples for the links might be lighter syntactically, with different pros and cons.

The structure suggested by Sloum was: ```python links = { "category1": [ { "title": "Tildegit", "link": "https://tildegit.org", "user": "sloum", "time": 1574641578, "replies": [ {"user": "asdf", "time": 1574328572, "reply": "Me too!"}, {"user": "cmccabe", "time": 1575528561, "reply": "Me three!"} ] } ], "other category": [ { "title": "Stuff", "link": "https://blah.com", "user": "someuser", "time": 1574641578, "replies": [] } ] } ``` I like this approach. Using a class or named tuples for the links might be lighter syntactically, with different pros and cons.
Author
Owner

I think this data structure looks pretty good. Just to make sure I have it correct, would the following be the way a second link would be represented within the "category1" category?

links = {
    "category1": [
        {
            "title": "Tildegit",
            "link": "https://tildegit.org",
            "user": "sloum",
            "time": 1574641578,
            "replies": [
                {"user": "asdf", "time": 1574328572, "reply": "Me too!"},
                {"user": "cmccabe", "time": 1575528561, "reply": "Me three!"}
            ]
        },
        {
            "title": "Github",
            "link": "https://github.com",
            "user": "sloum",
            "time": 1574641578,
            "replies": [
                {"user": "asdf", "time": 1574328572, "reply": "Never heard of it!"},
                {"user": "cmccabe", "time": 1575528561, "reply": "Me either!"}
            ]
        }
    ],
    "other category": [
        {
            "title": "Stuff",
            "link": "https://blah.com",
            "user": "someuser",
            "time": 1574641578,
            "replies": []
        }
    ]
}
I think this data structure looks pretty good. Just to make sure I have it correct, would the following be the way a second link would be represented within the "category1" category? ```python links = { "category1": [ { "title": "Tildegit", "link": "https://tildegit.org", "user": "sloum", "time": 1574641578, "replies": [ {"user": "asdf", "time": 1574328572, "reply": "Me too!"}, {"user": "cmccabe", "time": 1575528561, "reply": "Me three!"} ] }, { "title": "Github", "link": "https://github.com", "user": "sloum", "time": 1574641578, "replies": [ {"user": "asdf", "time": 1574328572, "reply": "Never heard of it!"}, {"user": "cmccabe", "time": 1575528561, "reply": "Me either!"} ] } ], "other category": [ { "title": "Stuff", "link": "https://blah.com", "user": "someuser", "time": 1574641578, "replies": [] } ] } ```
Sign in to join this conversation.
No description provided.