Class: Parse::JobSchedule

Inherits:
Object show all
Defined in:
lib/parse/model/classes/job_schedule.rb

Overview

Note:

This collection is consumed by external scheduling tooling, not by Parse Server itself. #params is stored as a JSON string (not an Object) per the canonical Parse Server schema; use #parsed_params to decode. _JobSchedule is hardcoded master-key-only at Parse Server's REST layer (SharedRest.js) — CLP changes via Object.set_clp have no effect.

This class represents the data and columns contained in the standard Parse _JobSchedule collection. Rows here define recurring runs for background jobs registered via +Parse.Cloud.job(...)+. The collection is populated by the Parse Dashboard's "Schedule a Job" UI and consumed by Parse Server's scheduler.

The default schema for JobSchedule is as follows:

class Parse::JobSchedule < Parse::Object # See Parse::Object for inherited properties...

 property :job_name
 property :description
 property :params              # JSON-encoded string of params (server stores as String)
 property :start_after         # ISO 8601 timestamp string for first run
 property :days_of_week, :array
 property :time_of_day         # "HH:MM:SS"
 property :last_run, :integer  # epoch seconds of the previous run
 property :repeat_minutes, :integer

end

Defining and scheduling a job

The job itself is registered in Parse Server's Cloud Code (server-side JavaScript). See JobStatus for the +Parse.Cloud.job(...)+ registration example.

Schedules are normally created through the Parse Dashboard "Jobs" tab, which writes the _JobSchedule row for you. The dashboard exposes:

_JobSchedule is a metadata collection: it stores schedule definitions but Parse Server itself does not auto-trigger jobs from these rows. The actual dispatch is performed by external tooling (e.g. +parse-server-scheduler+, dashboard-driven cron wrappers, or a sidecar process) which reads _JobSchedule and fires +POST /parse/jobs/+ at the appropriate times. Run status rows then appear in JobStatus.

Reading a schedule from Ruby

schedule = Parse::JobSchedule.for_job("nightlyCleanup").first schedule.parsed_params # => { "dryRun" => false } (decoded from params) schedule.time_of_day # => "03:00:00" schedule.days_of_week # => ["mon","tue","wed","thu","fri"]

See Also:

Constant Summary

Constants inherited from Object

Object::BUILTIN_PARSE_CLASS_NAMES, Object::IDENTIFICATION_FIELDS, Object::VALID_ACL_POLICIES

Constants included from Core::Schema

Core::Schema::DEFAULT_PUBLIC_CLP, Core::Schema::SCHEMA_READONLY_CLASSES

Constants included from Core::Describe

Core::Describe::ALL_SECTIONS, Core::Describe::CORE_FIELD_KEYS, Core::Describe::LOCAL_SECTIONS, Core::Describe::NETWORK_SECTIONS

Constants included from Core::Indexing

Core::Indexing::MAX_INDEXES_PER_COLLECTION, Core::Indexing::PARSE_MANAGED_ARRAY_FIELDS, Core::Indexing::SENSITIVE_FIELDS

Constants included from Core::SearchIndexing

Core::SearchIndexing::ALLOWED_INDEX_TYPES, Core::SearchIndexing::INDEX_NAME_PATTERN

Constants included from Core::Fetching

Core::Fetching::NON_SERIALIZABLE_IVARS

Constants included from Core::EmbedManaged

Core::EmbedManaged::WRITER_KEY

Constants included from Core::ParseReference

Core::ParseReference::OBJECT_ID_LENGTH, Core::ParseReference::SEPARATOR

Constants included from Core::FieldGuards

Core::FieldGuards::GUARD_MODES

Constants included from Properties

Properties::BASE, Properties::BASE_FIELD_MAP, Properties::BASE_KEYS, Properties::CORE_FIELDS, Properties::DELETE_OP, Properties::PROTECTED_INITIALIZE_KEYS, Properties::PROTECTED_MASS_ASSIGNMENT_KEYS, Properties::TYPES

Constants inherited from Pointer

Pointer::ATTRIBUTES, Pointer::OBJECT_ID_FORMAT

Constants inherited from Model

Model::CLASS_AUDIENCE, Model::CLASS_INSTALLATION, Model::CLASS_JOB_SCHEDULE, Model::CLASS_JOB_STATUS, Model::CLASS_PRODUCT, Model::CLASS_PUSH_STATUS, Model::CLASS_ROLE, Model::CLASS_SCHEMA, Model::CLASS_SESSION, Model::CLASS_USER, Model::ID, Model::KEY_CLASS_NAME, Model::KEY_CREATED_AT, Model::KEY_OBJECT_ID, Model::KEY_UPDATED_AT, Model::OBJECT_ID, Model::TYPE_ACL, Model::TYPE_BYTES, Model::TYPE_DATE, Model::TYPE_FIELD, Model::TYPE_FILE, Model::TYPE_GEOPOINT, Model::TYPE_NUMBER, Model::TYPE_OBJECT, Model::TYPE_POINTER, Model::TYPE_POLYGON, Model::TYPE_RELATION

Instance Attribute Summary collapse

Attributes inherited from Object

#acl, #created_at, #id, #updated_at

Attributes inherited from Pointer

#id, #parse_class

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#[], #[]=, #__type, #_resolve_acl_owner_id, #_resolve_default_acl, #acl_changed?, acl_owner_field, acl_policy, acl_policy_setting, #acl_was, #acl_will_change!, #after_create, #after_destroy, #after_save, #after_update, #after_validation, #apply_defaults!, #around_create, #around_destroy, #around_save, #around_update, #around_validation, #as_json, #autofetch_disabled?, #before_create, #before_destroy, #before_save, #before_update, #before_validation, build, #changed, #changed?, class_permissions, #clear_attribute_change!, #clear_changes!, #clear_partial_fetch_state!, default_acls, describe_access, #disable_autofetch!, #enable_autofetch!, #existed?, fetch_clp, #fetched?, #fetched_keys, #fetched_keys=, #field_was_fetched?, #filter_for_user, filter_results_for_user, #fully_fetched?, #has?, #has_selective_keys?, #initialize, #keys, master_only_class!, #nested_fetched_keys, #nested_fetched_keys=, #nested_keys_for, #new?, #parse_class, #partially_fetched?, #persisted?, pointer, #pretty, private_acl!, protect_fields, #reload!, roles_for_user, #rollback!, #run_after_create_callbacks, #run_after_delete_callbacks, #run_after_save_callbacks, #schema, #search_highlights, #search_score, set_class_access, set_clp, set_default_acl, set_default_clp, set_read_user_fields, set_write_user_fields, #twin, unlistable_class!, update_clp!, #updates, #valid?, #validate!, #vector_score, wait_for, watch, webhook, webhook_function

Methods included from Core::Querying

#all, #all_as, #count, #count_distinct, #cursor, #distinct, #each, #find, #find_cached, #first, #first_as, #last_updated, #latest, #literal_where, #newest, #oldest, #query, #scope, #subscribe

Methods included from Core::Schema

#_default_class_level_permissions_for_upgrade, #auto_upgrade!, #create_schema, #fetch_schema, #reset_clp!, #schema, #update_schema

Methods included from Core::Describe

#describe

Methods included from Core::Indexing

#apply_indexes!, #indexes_plan, #mongo_geo_index, #mongo_index, #mongo_index_declarations, #mongo_relation_index

Methods included from Core::SearchIndexing

#apply_search_indexes!, #mongo_search_index, #mongo_search_index_declarations, #search_indexes_plan

Methods included from Core::VectorSearchable

#find_similar

Methods included from Agent::MetadataDSL

#agent_description, #agent_methods, #property_descriptions, #property_enum_descriptions

Methods included from Core::Actions

#_deleted?, #change_requests, #changes_applied!, #changes_payload, #create, #destroy, #destroy_request, #op_add!, #op_add_relation!, #op_add_unique!, #op_destroy!, #op_increment!, #op_remove!, #op_remove_relation!, #operate_field!, #prepare_save!, #relation_change_operations, #save, #save!, #set_attributes!, #update, #update!, #update_relations, #uri_path

Methods included from Core::Fetching

#autofetch!, #fetch, #fetch!, #fetch_cache!, #fetch_json, #fetch_object, #prepare_for_dirty_tracking!

Methods included from Associations::HasMany

has_many, #relation_changes?, #relation_updates, #relations

Methods included from Associations::BelongsTo

belongs_to, #key?

Methods included from Associations::HasOne

has_one

Methods included from Core::ParseReference

format, generate_object_id, parse

Methods included from Core::FieldGuards

#apply_field_guards!

Methods included from Properties

#apply_attributes!, #attribute_changes?, #attribute_updates, #attributes, #attributes=, #field_map, #fields, #format_operation, #format_value

Methods inherited from Pointer

#==, #[], #[]=, #__type, #attributes, #className, #fetch, #fetch_cache!, #fetch_json, #fetch_object, #fetched?, #hash, #initialize, #json_hash, #method_missing, #pointer, #pointer?, #present?, #respond_to_missing?, #search_highlights, #search_score, #sig, #vector_score

Methods inherited from Model

#dirty?, find_class

Methods included from Client::Connectable

#client

Constructor Details

This class inherits a constructor from Parse::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Parse::Pointer

Instance Attribute Details

#days_of_weekArray

Array of day-of-week identifiers indicating which days the job is eligible to run. The exact token set (e.g. +"mon"+/+"tue"+/... vs. +0+..+6+) is determined by the scheduler tooling that writes the row; the Parse Server schema only requires that the column hold an array.

Returns:



109
# File 'lib/parse/model/classes/job_schedule.rb', line 109

property :days_of_week, :array

#descriptionString

Free-form description of this scheduled job, as entered in the dashboard.

Returns:



88
# File 'lib/parse/model/classes/job_schedule.rb', line 88

property :description

#job_nameString

The registered job name to invoke on each run.

Returns:



82
# File 'lib/parse/model/classes/job_schedule.rb', line 82

property :job_name

#last_runInteger

Raw Number timestamp recording the previous run. The unit is scheduler-defined — most external schedulers write +Date.now()+ milliseconds, but the canonical Parse Server schema only declares +Number+ and does not pin a unit. Treat values written by one scheduler as opaque to others.

Returns:

  • (Integer)


124
# File 'lib/parse/model/classes/job_schedule.rb', line 124

property :last_run, :integer

#paramsString

JSON-encoded string of parameters to pass to the job. Stored as a String in the canonical Parse Server schema to avoid the nested-key character restrictions that apply to Object columns.

Returns:



95
# File 'lib/parse/model/classes/job_schedule.rb', line 95

property :params

#repeat_minutesInteger

Interval in minutes between runs, when the schedule is interval-based rather than time-of-day-based.

Returns:

  • (Integer)


130
# File 'lib/parse/model/classes/job_schedule.rb', line 130

property :repeat_minutes, :integer

#start_afterString

ISO 8601 timestamp string indicating the earliest time the first scheduled run may fire.

Returns:



101
# File 'lib/parse/model/classes/job_schedule.rb', line 101

property :start_after

#time_of_dayString

"HH:MM:SS" string indicating the time of day at which the job should run on each eligible day.

Returns:



115
# File 'lib/parse/model/classes/job_schedule.rb', line 115

property :time_of_day

Class Method Details

.for_job(name) ⇒ Parse::Query

Query scope for schedules belonging to a specific job by name.

Parameters:

Returns:



136
137
138
# File 'lib/parse/model/classes/job_schedule.rb', line 136

def for_job(name)
  query(job_name: name.to_s)
end

Instance Method Details

#parsed_paramsHash?

Decoded form of #params, which is stored on the wire as a JSON string per the canonical Parse Server schema. Returns the parsed Hash, or nil if params is blank, or nil if the stored string is not valid JSON (Parse Dashboard occasionally writes a non-JSON description string here for ad-hoc schedules — we swallow the parse error rather than crash the caller).

Returns:



148
149
150
151
152
153
# File 'lib/parse/model/classes/job_schedule.rb', line 148

def parsed_params
  return nil if params.blank?
  JSON.parse(params)
rescue JSON::ParserError
  nil
end