Mantilogs - The Micrologs and pagination.

Mantilogs - The Micrologs and pagination.

Today I will work on microlog serialization and the interface to add them. I expect this to go smoothly and allow me to work on starting the cleaning log refactor and possibly finishing it and adding an interface for it as well before I clock out.

It's going to suck figuring out pagination, isn't it? Better grit my teeth, keep my head down and keep shuffling forward through the documentation.

Alright, looks like the ideal way to work this would be Page based, that way I can just fire a request with an incremental page number, then repopulate the logs display.

Of course I don't need this yet for the interface but I will tomorrow so I may as well modify my Viewsets now, while I am in here lookin' at em.

That was relatively painless, though I guess we'll know tomorrow. I've written my own pagination functions in the past, it's not hard but I am glad this saves me time. (I hope)

Back to serializing the micrologs.

There we are, paginated and serialized.

Now on to the interface.

AH-HAH! I knew pagination would kick me in the dick eventually. I need to go back through all my JSON processors and modify them to look at the results field now, since all the data was moved around.

It wont take long but I knew something would break.

var response = json.get_data()["results"]

Need to append ["results"] to extract the data from indices and lists.

Micrologs post is working now.


Onward to the cleaning logs, looks like.

Now do I want to refactor the model or build a UI to interact with the one I already have? Would it be better if I simplified it like I did the other logs or should I have tank objects be individually selectable via foreign key as it is now? Hmm...

Think think think...

Alas, I already had things quite simple.

# Cleaned Specific Item(s) Array of Tank Objects (Where objects in Tank).
    items_cleaned = models.CharField(max_length=1024, blank=True)

I suppose I originally planned to have this be a one to many relationship and for some reason or another just made it text? Good job there, brain. I knew I had to get in here and refactor things eventually but geezus...

I guess I will just use it as it is for now and have that char field populated by IDs of tank objects in CSV format... Might want to increase max_length for that if tanks get bigger with more objects. So let's say 2048? Unless the IDs are integer based rather than UUIDs like most things... let's see...

Yep UUIDs.

Alas, I have serialized the tanks, tank objects and tank cleaning logs, yet the hour of lunch dawns. This will have to be completed tomorrow. I need to boil some showering water and have lunch. Then some other things must be done.

Clocking out, I'm afraid. Though it's probably for the best, there will be much work required for tank cleaning logs to be properly added and displayed.