Skip to content

Firestore Collection Log

Felix Beil edited this page Apr 28, 2020 · 2 revisions
Name log
Context order document
Document IDs unix time (milliseconds)

The log collection stores log messages that are associated with a single order. Thus it is a sub-collection of an order document. The log messages should not be used to e.g. determine the current status of an order. Instead they are purely for informational purposes, e.g. to know what happened with an order in case something went wrong.

The log documents are named based on the time that they have been created to ensure a chronological order in the database. The name is the creation time in unix milliseconds. This should also ensure, that names are unique as it is very unlikely for two distinct users to operate on the same order at the exact same millisecond (The only operation that multiple users are allowed to do is accepting an order).

Document structure

The documents stored in the log collection each represent a single log message with the following fields.

  • timestamp (timestamp)
    The time at which the log message has been generated. Should there be an inconsistency between this field and the name of the document, then this field is the definitive timestamp.
  • account_id (string)
    The id of the account that caused the action. If the action was not performed by a user, a string representative for the entity that made the change is used. For the twilio bot this strings would be set to twilio.
  • message (string)
    The actual content of the log message. It defines which kind of action has been performed on the order. There is a predefined set of actions:
    • created: The order has been created (this will only be done by the bot).
    • assigned: A user has accepted the order and thus the order has been assigned to that user.
    • unassigned: A user was unable to execute the order. Thus the order is now again open for other users to accept.
    • closed: The order has been executed sucessfully by a user.
    • expired: No user has accepted and executed the order within a certain amount of time after creation.
    • fixed: The order was invalid and has been fixed. It is now open for all users to accept.

Example

An example document /order/abcdefgHijk5mnopqrsT/log/1585743824590 could look like this (JSON representation of the data):

{
  "timestamp": 2020-04-01 14:23:44,
  "account_id": "abcdefghi6KLmn0pqrst",
  "message": "assigned"
}
Clone this wiki locally