Skip to content

Instantly share code, notes, and snippets.

View drexel-ue's full-sized avatar

IKesh Pack drexel-ue

  • Ohio
View GitHub Profile
import 'dart:async';
import 'package:aqueduct/aqueduct.dart';
import 'package:faker/faker.dart';
import 'package:uuid/uuid.dart';
class Migration9 extends Migration {
@override
Future upgrade() async {}
@override
@drexel-ue
drexel-ue / user_mapper
Last active July 15, 2019 14:24
basically, the user_mapper maps ids from _user, so that if a user is deleted, random user can still be picked without worrying about a number being generated that doesnt match an existing user
create table user_mapper (id serial, user_id int);
create index on user_mapper (id);
create index on user_mapper (user_id);
create or replace function user_mapper_insert()
Returns trigger as
$body$
begin
QUERY:
final alertQuery = Query<User>(context)
..where((User user) => user.id).equalTo(id)
..join(set: (User user) => user.likes)
.join(object: (Like like) => like.liker)
.returningProperties((User user) => [user.displayName])
..join(set: (User user) => user.shares)
.join(object: (Share share) => share.sharer)
.returningProperties((User user) => [user.displayName]);
QUERY:
final alertQuery = Query<User>(context)
..join(set: (User user) => user.likes).returningProperties(
(Like like) => [like.createdAt, like.liker.displayName])
..join(set: (User user) => user.shares).returningProperties(
(Share share) => [share.createdAt, share.sharer.displayName]);
RESPONSE:
{
'user' : {
'id' : 2,
'name' : 'taco',
'likes' : [
{
'id' : 3,
'video_id' : 23,
'liker_id' : 3,
'likee_id' : 2,
2019-06-22 20:53:31.622515
[SEVERE] aqueduct: GET /videoData/56 22285ms 500 {user-agent : Dart/2.3 (dart:io)\naccept-encoding : gzip\ncontent-length : 0\nhost : 10.0.2.2:8888\nauthorization : Bearer 8VlIFnNrPF0LbedAmE2pZA1Sc8RdjU8K\n} NoSuchMethodError: The getter 'length' was called on null.
Receiver: null
Tried calling: length
this is the offending code:
..route('/videoUpload')
List.generate(profileBloc.content.length, (int index) {
final vid = profileBloc.content[index];
final controller =
VideoPlayerController.network(vid.downloadUrl);
return SizedBox(
height: height * 0.3,
width: width * 0.3,
child: Column(
children: <Widget>[
VideoPlayer(controller),
@Operation.post()
Future<Response> handleUpload() async {
final transformer = MimeMultipartTransformer(
request.raw.headers.contentType.parameters["boundary"]);
final parts = await transformer
.bind(Stream.fromIterable([await request.body.decode<List<int>>()]))
.toList();
parts.forEach((MimeMultipart part) {
part.listen((List<int> data) async {
await File(
void _uploadVideo(UserData userData) async {
String selectedFilter = _filterTitleSubject.value ?? 'Normal';
final url = 'http://10.0.2.2:8888/videos';
final body = {
'userID': userData.id,
'createdBy': userData.displayName,
'appliedFilter': selectedFilter,
'title': title,
'aspectRatio': json.encode(cameraController.value.aspectRatio),
'content': content,
void _uploadVideo(UserData userData) async {
String selectedFilter = _filterTitleSubject.value ?? 'Normal';
final url = 'http://10.0.2.2:8888/videos';
final body = {
'video': base64Encode(await videoFile.readAsBytes()),
'userID': userData.id,
'createdBy': userData.displayName,
'appliedFilter': selectedFilter,
'title': title,
'aspectRatio': cameraController.value.aspectRatio,