Skip to content

Commit

Permalink
remove some old collection code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Sep 12, 2023
1 parent eaf0355 commit 7d5f59a
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 152 deletions.
17 changes: 0 additions & 17 deletions app/controllers/api/v1/collections_controller.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/api/v1/collections/_collection.json.jbuilder

This file was deleted.

1 change: 0 additions & 1 deletion app/views/api/v1/collections/index.json.jbuilder

This file was deleted.

1 change: 0 additions & 1 deletion app/views/api/v1/collections/show.json.jbuilder

This file was deleted.

26 changes: 0 additions & 26 deletions lib/tasks/projects.rake
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
require 'csv'

namespace :projects do
task :opensustainabletech => :environment do

collection = Collection.find_or_create_by!(name: 'Open Sustainable Technology', url: 'https://opensustain.tech/')

url = 'https://github.com/protontypes/open-sustainable-technology/raw/main/analysis/csv/projects.csv'

conn = Faraday.new(url: url) do |faraday|
faraday.response :follow_redirects
faraday.adapter Faraday.default_adapter
end

resp = conn.get

csv = CSV.parse(resp.body, headers: true)

csv.each_with_index do |row, i|
next if row['git_url'].blank?
puts "#{i} #{row['git_url']}"
# remove .git from the end of the URL
git_url = row['git_url'].gsub(/\.git$/, '')
project = collection.projects.find_or_create_by!(url: git_url)
project.sync
end

end

desc 'sync projects'
task :sync => :environment do
Project.sync_least_recently_synced
Expand Down
105 changes: 2 additions & 103 deletions openapi/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,88 +84,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Project'
/collections:
get:
ost: get collections
operationId: getCollections
tags:
- collections
parameters:
- name: page
in: query
description: pagination page number
required: false
schema:
type: integer
- name: per_page
in: query
description: Number of records to return
required: false
schema:
type: integer
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Collection'
/collections/{id}:
get:
ost: get a collection by id
operationId: getCollection
tags:
- collections
parameters:
- in: path
name: id
schema:
type: integer
required: true
description: id of the collection
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Collection'
/collections/{id}/projects:
get:
ost: get projects in a collection
operationId: getCollectionProjects
tags:
- collections
parameters:
- in: path
name: id
schema:
type: integer
required: true
description: id of the collection
- name: page
in: query
description: pagination page number
required: false
schema:
type: integer
- name: per_page
in: query
description: Number of records to return
required: false
schema:
type: integer
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Project'

components:
schemas:
Project:
Expand Down Expand Up @@ -206,24 +125,4 @@ components:
updated_at:
type: string
format: date-time
Collection:
type: object
properties:
id:
type: integer
name:
type: string
url:
type: string
description:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
projects_url:
type: string
html_url:
type: string

0 comments on commit 7d5f59a

Please sign in to comment.