Class: DynamicLinks::GenerateShortLinksJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/dynamic_links/generate_short_links_job.rb

Overview

This job generates short links in the background It is intended to be run periodically We can find available short links by querying the database with query: ShortenedUrl.where(available: true)

To use this strategy, invoke this cli command first: ‘rails generate dynamic_links:add_kgs_migration`

Instance Method Summary collapse

Instance Method Details

#perform(num_links = 100) ⇒ Object

Parameters:

  • num_links (Integer) (defaults to: 100)

    Number of short links to generate



13
14
15
16
17
18
19
# File 'app/jobs/dynamic_links/generate_short_links_job.rb', line 13

def perform(num_links = 100)
  num_links.times do
    # TODO
    # Generate a unique short code
    # Store the short code in the database
  end
end