circlesland / o-platform

GNU Affero General Public License v3.0
3 stars 1 forks source link

Collect UBI only once per day (and device/tab) #817

Closed jaensen closed 2 years ago

jaensen commented 2 years ago

Client:

  1. Every client queries the last ubi timestamp from the api
  2. Every client sets a timer that is due 24h after the last ubi
  3. On 'timer due':
    • every minute while last ubi > 24h:
    • all clients enqueue a "request_ubi"-job with the following parameters:
      • Id fields: safeAddress, year, month, day, hour
      • Payload fields: sessionId

Api:

  1. The api creates one "request_ubi"-worker instance for the first recognized enqueued job with this id
  2. The job worker sends a "request_ubi" notification to the client with the "sessionId" from the payload and waits up to one minute for a corresponding "crc_minting"-event from the blockchain indexer

Success case:

  1. The client requests the ubi
  2. The waiting job worker receives the "crc_minting" event and completes successfully
  3. Client's loop at 3) ends

Client unavailable/UBI not requested case:

  1. The job worker times-out and the corresponding job fails.
  2. Client's loop at 3) enqueues a new job