<commit_before>package api100

import (
	"encoding/json"
	"net/http"
	"strconv"

	db100 "github.com/Chaosvermittlung/funkloch-server/db/v100"
	"github.com/carbocation/interpose"
	"github.com/gorilla/mux"
)

func getBoxRouter(prefix string) *interpose.Middleware {
	r, m := GetNewSubrouter(prefix)
	r.HandleFunc("/", postBoxHandler).Methods("POST")
	r.HandleFunc("/list", listBoxesHandler).Methods("GET")
	r.HandleFunc("/{ID}", getBoxHandler).Methods("GET")
	r.HandleFunc("/{ID}", patchBoxHandler).Methods("PATCH")
	r.HandleFunc("/{ID}", deleteBoxHandler).Methods("DELETE")
	r.HandleFunc("/{ID}/items", getBoxItemsHandler).Methods("GET")
	r.HandleFunc("/{ID}/items/add/{IID}", addItemtoBoxHandler).Methods("POST")
	r.HandleFunc("/{ID}/items/remove/{IID}", removeItemfromBoxHandler).Methods("POST")
	return m
}

func convertBoxListEntryinBoxResponse(b db100.BoxlistEntry) boxResponse {
	var br boxResponse
	br.Box.BoxID = b.BoxID
	br.Box.Code = b.Code
	br.Box.Description = b.Description
	br.Store.StoreID = b.StoreID
	br.Store.Adress = b.Adress
	br.Store.ManagerID = b.ManagerID
	br.Store.Name = b.Name
	br.User.UserID = b.ManagerID
	br.User.Username = b.Username
	br.User.Email = b.Email
	br.User.Right = db100.UserRight(b.Right)
	return br
}

func convertBoxListinBoxResponseList(bb []db100.BoxlistEntry) []boxResponse {
	var res []boxResponse
	for _, b := range bb {
		br := convertBoxListEntryinBoxResponse(b)
		res = append(res, br)
	}
	return res
}<commit_msg>Redoing the endpoints for item adding and removing<commit_after>package api100

import (
	"encoding/json"
	"net/http"
	"strconv"

	db100 "github.com/Chaosvermittlung/funkloch-server/db/v100"
	"github.com/carbocation/interpose"
	"github.com/gorilla/mux"
)

func getBoxRouter(prefix string) *interpose.Middleware {
	r, m := GetNewSubrouter(prefix)
	r.HandleFunc("/", postBoxHandler).Methods("POST")
	r.HandleFunc("/list", listBoxesHandler).Methods("GET")
	r.HandleFunc("/{ID}", getBoxHandler).Methods("GET")
	r.HandleFunc("/{ID}", patchBoxHandler).Methods("PATCH")
	r.HandleFunc("/{ID}", deleteBoxHandler).Methods("DELETE")
	r.HandleFunc("/{ID}/items", getBoxItemsHandler).Methods("GET")
	r.HandleFunc("/{ID}/items/{IID}", addItemtoBoxHandler).Methods("POST")
	r.HandleFunc("/{ID}/items/{IID}", removeItemfromBoxHandler).Methods("DELETE")
	return m
}

func convertBoxListEntryinBoxResponse(b db100.BoxlistEntry) boxResponse {
	var br boxResponse
	br.Box.BoxID = b.BoxID
	br.Box.Code = b.Code
	br.Box.Description = b.Description
	br.Store.StoreID = b.StoreID
	br.Store.Adress = b.Adress
	br.Store.ManagerID = b.ManagerID
	br.Store.Name = b.Name
	br.User.UserID = b.ManagerID
	br.User.Username = b.Username
	br.User.Email = b.Email
	br.User.Right = db100.UserRight(b.Right)
	return br
}

func convertBoxListinBoxResponseList(bb []db100.BoxlistEntry) []boxResponse {
	var res []boxResponse
	for _, b := range bb {
		br := convertBoxListEntryinBoxResponse(b)
		res = append(res, br)
	}
	return res
}
{'fraction_non_alphanumeric': 0.15956727518593644, 'fraction_numerical': 0.012170385395537525, 'mean_word_length': 5.2690677966101696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4854703', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1070, 'n_words': 175}