Class: Forem::AdminConcept
- Inherits:
-
APIResource
- Object
- ForemObject
- APIResource
- Forem::AdminConcept
- Extended by:
- Forem::APIOperations::List, Forem::APIOperations::Retrieve
- Includes:
- Forem::APIOperations::Delete
- Defined in:
- lib/forem/resources/admin_concept.rb
Overview
Represents a Concept managed through the admin-only Concepts API.
Concepts are curated topics that Forem uses to classify articles and
comments via embedding similarity. The admin endpoints under
/api/admin/concepts expose full CRUD over those records plus a
trigger_lookback action that re-runs classification over older content.
Every endpoint requires an API key belonging to a super admin — a regular
user key receives HTTP 401.
Read-only access to the public concept endpoints lives on Concept; this resource is strictly the administrative surface.
Available operations:
- +List+ — GET /api/admin/concepts
- +Retrieve+ — GET /api/admin/concepts/:id
- +create+ — POST /api/admin/concepts
- +update+ — PUT /api/admin/concepts/:id
- +Delete+ — DELETE /api/admin/concepts/:id
- +trigger_lookback+ — POST /api/admin/concepts/:id/trigger_lookback
Concept Fields
id(Integer) — Unique identifiername(String, required) — Display name, max 100 charactersslug(String) — Generated fromnameby the API; not writabledescription(String) — Generated fromnamewhen omitted on createparent_id(Integer) — Optional parent concept, forming a hierarchysimilarity_threshold(Float) — Cosine similarity cutoff between0.0and1.0used when classifying records (may benull)score(Float) — Ranking score for the conceptmax_lookback_days(Integer) — How far back classification has already been run; read-only (set bytrigger_lookback, never by create/update)created_at/updated_at(String) — ISO 8601 timestamps
The list endpoint returns a trimmed projection (+id+, name, slug,
description, parent_id, similarity_threshold, max_lookback_days,
created_at, updated_at) ordered by name, while the show endpoint
returns the full record.
Writable attributes
Only name, description, parent_id, similarity_threshold, and
score are permitted on create and update. Any other attribute (notably
slug and max_lookback_days) is silently ignored by the API. Attributes
are sent wrapped in a concept object, which this resource does for you.
Constant Summary collapse
- OBJECT_NAME =
"admin_concept"- RESOURCE_PATH =
"/api/admin/concepts"
Instance Attribute Summary
Attributes inherited from ForemObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ AdminConcept
Create a new concept.
-
.trigger_lookback(id, params = {}, opts = {}) ⇒ ForemObject
Queue a classification lookback for a concept.
-
.update(id, params = {}, opts = {}) ⇒ AdminConcept
Update an existing concept.
Instance Method Summary collapse
-
#trigger_lookback(days, opts = {}) ⇒ ForemObject
Queue a classification lookback for this concept instance.
Methods included from Forem::APIOperations::List
Methods included from Forem::APIOperations::Retrieve
Methods included from Forem::APIOperations::Delete
Methods inherited from APIResource
#refresh, resource_path, #resource_url
Methods inherited from ForemObject
#==, #[], #[]=, construct_from, cursor_list, #initialize, #inspect, #method_missing, paginated_list, #respond_to_missing?, #to_hash
Methods included from Forem::APIOperations::Request
Constructor Details
This class inherits a constructor from Forem::ForemObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Forem::ForemObject
Class Method Details
.create(params = {}, opts = {}) ⇒ AdminConcept
Create a new concept.
Sends a POST to /api/admin/concepts with the attributes wrapped in a
concept object. The API generates the slug, and generates the
description and anchor embedding from name before saving, so creation
only requires a name.
88 89 90 91 92 |
# File 'lib/forem/resources/admin_concept.rb', line 88 def self.create(params = {}, opts = {}) requestor = opts[:requestor] resp = request(:post, resource_path, wrap_params(params), opts) construct_from(resp.parsed_body, requestor: requestor) end |
.trigger_lookback(id, params = {}, opts = {}) ⇒ ForemObject
Queue a classification lookback for a concept.
Sends a POST to /api/admin/concepts/:id/trigger_lookback, enqueueing
a background job that classifies records published within the last
days days. The requested days must be positive and strictly greater
than the concept's current max_lookback_days, otherwise the API
responds with HTTP 422.
132 133 134 135 136 |
# File 'lib/forem/resources/admin_concept.rb', line 132 def self.trigger_lookback(id, params = {}, opts = {}) requestor = opts[:requestor] resp = request(:post, "#{resource_path}/#{id}/trigger_lookback", params, opts) ForemObject.construct_from(resp.parsed_body, requestor: requestor) end |
.update(id, params = {}, opts = {}) ⇒ AdminConcept
Update an existing concept.
Sends a PUT to /api/admin/concepts/:id with the attributes wrapped
in a concept object. Changing name or description causes the API
to regenerate the concept's anchor embedding.
107 108 109 110 111 |
# File 'lib/forem/resources/admin_concept.rb', line 107 def self.update(id, params = {}, opts = {}) requestor = opts[:requestor] resp = request(:put, "#{resource_path}/#{id}", wrap_params(params), opts) construct_from(resp.parsed_body, requestor: requestor) end |
Instance Method Details
#trigger_lookback(days, opts = {}) ⇒ ForemObject
Queue a classification lookback for this concept instance.
163 164 165 166 167 |
# File 'lib/forem/resources/admin_concept.rb', line 163 def trigger_lookback(days, opts = {}) requestor = opts[:requestor] || @requestor resp = request(:post, "#{resource_url}/trigger_lookback", { days: days }, opts) ForemObject.construct_from(resp.parsed_body, requestor: requestor) end |