Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store timestamp in the log #2732

Closed
wants to merge 3 commits into from
Closed

Store timestamp in the log #2732

wants to merge 3 commits into from

Conversation

Antar1011
Copy link
Contributor

Resolves #2731

So that the data can be accessed without needing the folder structure.

So that the data can be accessed without needing the folder structure.
@Antar1011
Copy link
Contributor Author

And then I have a question about L1045/1048:

let tier = this.format.toLowerCase().replace(/[^a-z0-9]+/g, '');

Shouldn't this just be toId(this.format)?

Sorry--been coding in python too long.
@Zarel
Copy link
Member

Zarel commented Sep 2, 2016

Can we remove some redundant data while we're at it?

@Zarel
Copy link
Member

Zarel commented Sep 2, 2016

A lot of fields in p1rating/p2rating are superfluous. The individual formatid's and entryids, for one.

@Antar1011
Copy link
Contributor Author

That would be fine with me, but I'm not sure how to do it in a future-proofed way (say the colname in the db changes, then delete p1rating.formatid would throw an error, no?)

@Antar1011
Copy link
Contributor Author

Or if you're worried about space, you could always just tackle #2733

@Zarel
Copy link
Member

Zarel commented Sep 2, 2016

You're cute when talking about languages you don't know.

There's not a single language for which it's impossible to delete a key from a map if you're not sure if the key exists. Every language at the very least has a "does this key exist?" function (except ObjC for some weird reason).

Anyway, delete p1rating.formatid won't throw if p1rating.formatid doesn't exist, it just silently fails.

@Antar1011
Copy link
Contributor Author

Antar1011 commented Sep 2, 2016

@Zarel, as I said, I don't know how to do it in JS. I never said it wasn't possible to do it.

But let's identify the redundant keys:

That would be:

  • formatid
  • username (since it's encoded separately as p[n])
  • userid (since you can always toId(username))

And if we don't care about future-proofing, we can ditch

  • rpsigma
  • sigma

col1 (number of battles for the alt, even past the last reset) might be a useful, but seeing as how it's not documented, I'm fine with dropping it as well.

Does js have a "delete all" or do you just have to iterate?

@Zarel
Copy link
Member

Zarel commented Sep 2, 2016

Iterate.

I'm fine with all of the above, although keeping userid may be nice.

@@ -1037,6 +1037,9 @@ let BattleRoom = (() => {
logData.endType = this.battle.endType;
if (!p1rating) logData.ladderError = true;
const date = new Date();
logData.timestamp = date;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, JSON doesn't support storing dates. It will toJSON the date, which I believe makes it a string. Is that what you want, or do you want a numeric timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine with strings. In theory this could introduce TZ issues, but I'd rather have readability. If you care, I'm fine with numeric, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but you should probably do the conversion explicitly new Date().toString(), so future people who read your code know that it's intentional and not accidental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants