Merge branch 'order-implementations' into 'master'
Order implementations See merge request pastebin.run/server!97
This commit is contained in:
commit
2b2792145b
|
@ -0,0 +1 @@
|
|||
ALTER TABLE implementations DROP COLUMN ordering;
|
|
@ -0,0 +1,5 @@
|
|||
TRUNCATE implementation_wrappers;
|
||||
DELETE FROM implementations;
|
||||
|
||||
ALTER TABLE implementations ADD COLUMN ordering int NOT NULL;
|
||||
ALTER TABLE implementations ADD CONSTRAINT implementations_language_id_ordering_key UNIQUE (language_id, ordering);
|
|
@ -86,11 +86,14 @@ pub fn run(connection: &Connection) -> Result<(), Box<dyn Error>> {
|
|||
.execute(connection)?;
|
||||
}
|
||||
}
|
||||
for Implementation {
|
||||
for (
|
||||
i,
|
||||
Implementation {
|
||||
label,
|
||||
identifier: implementation_identifier,
|
||||
wrappers,
|
||||
} in implementations
|
||||
},
|
||||
) in (1..).zip(implementations)
|
||||
{
|
||||
languages::table
|
||||
.filter(languages::identifier.eq(&languages_identifier))
|
||||
|
@ -98,16 +101,24 @@ pub fn run(connection: &Connection) -> Result<(), Box<dyn Error>> {
|
|||
languages::language_id,
|
||||
label.as_sql::<Text>(),
|
||||
implementation_identifier.as_sql::<Text>(),
|
||||
i.as_sql::<Integer>(),
|
||||
))
|
||||
.insert_into(implementations::table)
|
||||
.into_columns((
|
||||
implementations::language_id,
|
||||
implementations::label,
|
||||
implementations::identifier,
|
||||
implementations::ordering,
|
||||
))
|
||||
.on_conflict((
|
||||
implementations::language_id,
|
||||
implementations::identifier,
|
||||
))
|
||||
.on_conflict((implementations::language_id, implementations::identifier))
|
||||
.do_update()
|
||||
.set(implementations::label.eq(&label))
|
||||
.set((
|
||||
implementations::label.eq(&label),
|
||||
implementations::ordering.eq(i),
|
||||
))
|
||||
.execute(connection)?;
|
||||
for (
|
||||
i,
|
||||
|
|
|
@ -74,6 +74,7 @@ pub fn api_language(
|
|||
let implementations = implementations::table
|
||||
.select((implementations::implementation_id, implementations::label))
|
||||
.filter(implementations::language_id.eq(language.id))
|
||||
.order(implementations::ordering)
|
||||
.load(&connection)
|
||||
.map_err(warp::reject::custom)?;
|
||||
let implementation_wrappers = ImplementationWrapper::belonging_to(&implementations)
|
||||
|
|
|
@ -4,6 +4,7 @@ table! {
|
|||
language_id -> Int4,
|
||||
identifier -> Text,
|
||||
label -> Text,
|
||||
ordering -> Int4,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user